SQL ͨÅä·û
ÔÚËÑË÷Êý¾Ý¿âÖеÄÊý¾Ýʱ£¬SQL ͨÅä·û¿ÉÒÔÌæ´úÒ»¸ö»ò¶à¸ö×Ö·û¡£
SQL ͨÅä·û±ØÐëÓë LIKE ÔËËã·ûÒ»ÆðʹÓá£
ÔÚ SQL ÖУ¬¿ÉʹÓÃÒÔÏÂͨÅä·û£º
ͨÅä·ûÃèÊö
%
Ìæ´úÒ»¸ö»ò¶à¸ö×Ö·û
_
½öÌæ´úÒ»¸ö×Ö·û
[charlist]
×Ö·ûÁÐÖеÄÈκε¥Ò»×Ö·û
[^charlist]
»òÕß
[!charlist]
²»ÔÚ×Ö·ûÁÐÖеÄÈκε¥Ò»×Ö·û
ÔʼµÄ±í (ÓÃÔÚÀý×ÓÖеÄ)£º
Persons ±í:
IdLastNameFirstNameAddressCity
1
Adams
John
Oxford Street
London
2
Bush
George
Fifth Avenue
New York
3
Carter
Thomas
Changan Street
Beijing
ʹÓà % ͨÅä·û
Àý×Ó 1
ÏÖÔÚ£¬ÎÒÃÇÏ£Íû´ÓÉÏÃæµÄ "Persons" ±íÖÐÑ¡È¡¾ÓסÔÚÒÔ "Ne" ¿ªÊ¼µÄ³ÇÊÐÀïµÄÈË£º
ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ SELECT Óï¾ä£º
SELECT * from Persons
WHERE City LIKE 'Ne%'
½á¹û¼¯£º
IdLastNameFirstNameAddressCity
2
Bush
George
Fifth Avenue
New York
Àý×Ó 2
½ÓÏÂÀ´£¬ÎÒÃÇÏ£Íû´Ó "Persons" ±íÖÐÑ¡È¡¾ÓסÔÚ°üº¬ "lond" µÄ³ÇÊÐÀïµÄÈË£º
ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ SELECT Óï¾ä£º
SELECT * from Persons
WHERE City LIKE '%lond%'
½á¹û¼¯£º
IdLastNameFirstNameAddressCity
1
Adams
John
Oxford Street
London
ʹÓà _ ͨÅä·û
Àý×Ó 1
ÏÖÔÚ£¬ÎÒÃÇÏ£Íû´ÓÉÏÃæµÄ "Persons" ±íÖÐÑ¡È¡Ãû×ֵĵÚÒ»¸ö×Ö·ûÖ®ºóÊÇ "eorge" µÄÈË£º
ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ SELECT Óï¾ä£º
SELECT * from Persons
WHERE FirstName LIKE '_eorge'
½á¹û¼¯£º
IdLastNameFirstNameAddressCity
2
Bush
George
Fifth Avenue
New York
Àý×Ó 2
½ÓÏÂÀ´£¬ÎÒÃÇÏ£Íû´Ó "Persons" ±íÖÐÑ¡È¡µÄÕâÌõ¼Ç¼µÄÐÕÊÏÒÔ "C" ¿ªÍ·£¬È»ºóÊÇÒ»¸öÈÎÒâ×Ö·û£¬È»ºóÊÇ "r"£¬È»ºóÊÇÈÎÒâ×Ö·û£¬È»ºóÊÇ "er"£º
ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ SELECT Óï¾ä£º
SELECT * from Persons
WHERE LastName LIKE 'C_r_er'
½á¹û¼¯£º
IdLastNameFirstNameAddressCity
3
Carter
Thomas
Changan Street
Beijing
ʹÓà [charlist] ͨÅä·û
Àý×Ó 1
ÏÖÔÚ£¬ÎÒÃÇÏ£Íû´ÓÉÏÃæµÄ "Persons" ±íÖÐÑ¡È¡¾ÓסµÄ³ÇÊÐÒÔ "A" »ò "L" »ò "N" ¿ªÍ·µÄÈË£º
ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ SELECT Óï¾ä£º
SELECT * from Persons
WHERE City LIKE '[ALN]%'
½á¹û¼¯£º
IdLastNameFirstNameAddressCity
1
Adams
John
Oxford Street
London
2
Bush
George
Fifth Avenue
New York
Àý×Ó 2
ÏÖÔÚ£¬ÎÒÃÇÏ£Íû´ÓÉÏÃæµÄ "Persons" ±íÖÐÑ¡È¡¾ÓסµÄ³ÇÊв»ÒÔ "A" »ò "L" »ò "N" ¿ªÍ·µÄÈË£º
ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ S
Ïà¹ØÎĵµ£º
select c0501 "¶©µ¥±àºÅ",
c0503 "¹©Ó¦É̱àÂë",a0302 "¹©Ó¦ÉÌÃû³Æ",
to_char(c0515,'yyyy.mm.dd') "¶©»õÈÕÆÚ",
to_char(c0516,'yyyy.mm.dd') "Ô¤¶¨½»»õÈÕÆÚ"
from c05,a03 where c0503=a0301 and
&nb ......
-sqlÊÂÎñ´¦Àí
----------------------Àí------------ÂÛ-----------------------
1.ʲôÊÇÊÂÎñ£ºÊÂÎñÊÇÒ»¸ö²»¿É·Ö¸îµÄ¹¤×÷Âß¼µ¥Ôª£¬ÔÚÊý¾Ý¿âϵͳÉÏÖ´Ðв¢·¢²Ù×÷ʱÊÂÎñÊÇ×öΪ×îСµÄ¿ØÖƵ¥ÔªÀ´Ê¹Óõġ£Ëû°üº¬µÄËùÓÐÊý¾Ý¿â²Ù×÷ÃüÁî×÷Ϊһ¸öÕûÌåÒ»ÆðÏòϵÌá½»»ò³·Ïû£¬ÕâÒ»×éÊý¾Ý¿â²Ù×÷ÃüÁîҪô¶¼Ö´ÐУ¬ÒªÃ´¶¼²»Ö´ÐС£
2.ÊÂÎ ......
jspÁ¬½Ósql server2005
£¨¾²âÊÔÁ¬½Ó³É¹¦£©
½Ó´¥Java»òÕßJSP£¬ÄÑÃâ»áʹÓõ½Êý¾Ý¿â
SQL Server
2000/2005£¨ÎÒʹÓÃ2005±ê×¼°æ[9.0.3054]²âÊÔ£©£¬¾¹ý×Ô¼ºµÄËÑË÷ºÍÑо¿£¬Ê¹ÓÃJDBCÁ¬½ÓSQL
Server³É¹¦£¬ÌØ´ËÕûÀí·½·¨£¨Ê¹ÓÃEclipse 3.2£©ÈçÏ¡£
×¼±¸¹¤×÷
Ê×ÏÈ£¬²Ù×÷ϵͳ
Öа²×°ºÃSQL Server
2000/2005£¬È ......
ÔÚ´óÐ͵ÄÊý¾Ý¿âÓ¦ÓÃÖУ¬¾³£»áÓöµ½²¿·ÖÊý¾ÝµÄÍÑ»úºÍ¶à¸öÊý¾Ý¿âµÄºÏ²¢ÎÊÌâ¡£±ÈÈçÏÖÔÚÓÐÒ»¸öÈ«Ê¡·¶Î§Ê¹ÓõÄÓ¦ÓóÌÐò£¬Ã¿¸öÊж¼²¿ÊðÁ˵¥¶ÀµÄÏàͬµÄÓ¦ÓóÌÐò·þÎñÆ÷ºÍÊý¾Ý¿â·þÎñÆ÷£¬Ã¿¸öÔÂÐèÒª½«È«Ê¡ËùÓÐÊеÄÊý¾ÝÈ«²¿»ã×ÜÆðÀ´ÓÃÓÚ³öÈ«Ê¡µÄ±¨±í£¬ÕâÊÇÒ»Öֺܳ£¼ûµÄÊý¾Ý¿âºÏ²¢ÎÊÌâ¡£ÔÙ±ÈÈçÎÒÃÇ×öÁËÒ»¸öSmartClientµÄÓ¦ÓóÌÐò£¬Ã¿¸ö¿ ......
SQLµ÷ÓÅ Ö® Á¬½Ó·½Ê½
JoinÊÇÒ»ÖÖÊÔͼ½«Á½¸ö±í½áºÏÔÚÒ»ÆðµÄν´Ê£¬Ò»´ÎÖ»ÄÜÁ¬½Ó2¸ö±í£¬±íÁ¬½ÓÒ²¿ÉÒÔ±»³ÆΪ±í¹ØÁª¡£ÔÚºóÃæµÄÐðÊöÖУ¬Ê¹ÓÔrow source”À´´úÌ攱픣¬ÒòΪʹÓÃrow source¸üÑϽ÷һЩ£¬²¢ÇÒ½«²ÎÓëÁ¬½ÓµÄ2¸örow source·Ö±ð³ÆΪrow source1ºÍrow source 2¡£Join¹ý³ÌµÄ¸÷¸ö²½Öè¾³£ÊÇ´®ÐвÙ×÷ ......