sqlÓï¾ä
select *from student
select student_id from student
select student_id ,student_name from student
select student_id student_name from student ½«student_name ×÷Ϊstudent_idµÄ±ðÃû´¦Àí
È磺 select student_id a from student
select a=student_id from student
´Óstudent±íÖзֱð¼ìË÷³öѧÉúµÄѧºÅ¡¢ÐÕÃûÐÅÏ¢²¢·Ö±ð¼ÓÉϓѧÉú”¡¢“ѧºÅ”µÄ±êÌâÐÅÏ¢¡£
select ѧºÅ=student_id,ѧÉú=student_name from student
´ó²¿·Ö²éѯ¶¼²»ÊÇÕë¶Ô±íÖÐËùÓÐÐеIJéѯ£¬¶øÊÇ´ÓÕû¸ö±íÖÐÑ¡³ö·ûºÏÌõ¼þµÄÐÅÏ¢£¬ÒªÊµÏÖÕâÑùµÄ²éѯ¾ÍÒªÓõ½
´Óstudent_course±íÖмìË÷³É¼¨Ð¡ÓÚ60·ÖµÄѧÉúÐÅÏ¢¡£
select grade from student_course where grade<60
select * from student_course order by student_id
select top 50 percent *from student_course order by student_id Êä³ö×ÜÐÐÊýµÄÒ»°ë
select top 10 *from student_course order by student_id Êä³öǰ10ÐÐ
‘2007-11-18’ convert cast
date'2007-11-18'
student_course±íÖмìË÷³É¼¨½éÓÚ60ÖÁ80·ÖÖ®¼äµÄѧÉúÐÅÏ¢¡£
select student_id,grade from student_course where grade between 60 and 80
´Óstudent_course±íÖмìË÷ѧºÅΪ‘g9940202’,‘g9940204’,‘g9940206’µÄѧÉúÐÅÏ¢¡£
select *from student_course where (student_id='g9940202')or(student_id='g9940204')or(student_id='g9940206')
select *from student_course
select distinct student_id from student_course
select *from student_course where (student_id='g9940202')or(student_id='g9940204')or(student_id='g9940206') order by student_id
´Óstudent±íÖзֱð¼ìË÷³öÐÕÕŵÄËùÓÐͬѧµÄ×ÊÁÏ£»Ãû×ֵĵڶþ¸ö×ÖÊÇ“ºì”»ò“ºç”µÄËùÓÐͬѧµÄ×ÊÁÏ
select *from student
select *from student where student_name like 'ÕÅ%'and student_name like '%ºì'or student_name like '%ºç'
select *from student where student_name like '_[ºì,ºç]%'
SELECT * from student WHERE student_name LIKE '_[ºì,ºç]%'
SELECT * from student WHERE student_name LIKE '_[^ºì,ºç]%'
SELECT * from&nbs
Ïà¹ØÎĵµ£º
-- FUN:´æ´¢¹ý³Ì·ÖÒ³
-- @Table nvarchar(255), -- ±íÃû
-- @Fields nvarchar(1000) = ' * ', -- ÐèÒª·µ»ØµÄÁÐ
-- @OrderField nvarchar(255), -- ÅÅÐòµÄ×Ö¶ÎÃû,Ò»°ãΪΨһ±êʶ
-- @OrderType bit = 0, -- ÉèÖÃÅÅÐòÀàÐÍ, ·Ç 0 ÖµÔò½µÐò
-- @PageSize int = 10, -- ÿҳÓжàÉÙÌõ¼Ç¼
-- @PageIndex int = 1, -- µÚ ......
Ó¦Ò»¸öÅóÓѵÄÒªÇó£¬ÌùÉÏÊղصÄSQL³£Ó÷ÖÒ³µÄ°ì·¨¡«¡«
±íÖÐÖ÷¼ü±ØÐëΪ±êʶÁУ¬[ID] int IDENTITY (1,1)
1.·ÖÒ³·½°¸Ò»£º(ÀûÓÃNot InºÍSELECT TOP·ÖÒ³)
Óï¾äÐÎʽ£º
SELECT TOP Ò³¼Ç¼ÊýÁ¿ *
from ±íÃû
WHERE (ID NOT IN
(SELECT TOP (ÿҳÐÐÊý*(Ò³Êý-1)) ID
from ±íÃû
ORDER BY ......
Suppose we have a recursive hierarchy stored in a relational database and we want to write it to XML. This might be for a variety of reasons – e.g. as a pre-cached input to a UI control, to export to another system using a pre-defined format, etc.
In SQL Server 2000, in order to ......
DB2 SQL PL
SQL PLÊÇDB2ËùÖ§³ÖµÄ¹ý³Ì»¯ÓïÑÔ£¬ËüÊÇSQL/PSM±ê×¼µÄÒ»¸ö×Ó¼¯¡£Æä¸ù¾ÝÓ¦Ó÷¶Î§²»Í¬£¬ÓÖ·ÖΪInline SQL PL£¬Embeded SQL PLºÍCompiled SQL PL¡£
Inline SQL PL
ÊÊÓ÷¶Î§£º´¥·¢Æ÷¡¢º¯ÊýºÍ·½·¨£¬Ö§³Ö²¿·ÖSQL PL£¬Ê¹ÓÃʱҪעÒâһЩÏÞÖÆ
Óï·¨¹æÔò£ºBEGIN ATOMIC ... END
Embeded SQL PL
ÊÊÓ÷¶Î§£ºÇ¶Èëʽ£¬Åäº ......