sqlÖÐÓÃʲôÀ´ÌåÏÖÌõ¼þ
sql ÖÐÌåÏÖÌõ¼þµÄ where Òªº¦×ÖÔÊÐíͨ¹ýÖ¸¶¨Ìõ¼þ¹ýÂ˼ͼ£¬Æ¾Ö¤Ìض¨Áлò±í´ïʽֵÏÞÖÆÒª¼ìË÷µÄÊý¾Ý¡£where Ìõ¼þÀàÐÍ°üÀ¨µÈÖµÌõ¼þ¡¢²»µÈÖµÌõ¼þ¡¢½ÏÁ¿Ìõ¼þ¡¢²¼¶ûÌõ¼þ¡¢¿ÕÖµÌõ¼þ¡¢like Ìõ¼þ¡¢in Ìõ¼þºÍ between Ìõ¼þ¡£
SQL ÖÐÌåÏÖÌõ¼þµÄÒªº¦×Ö
WHERE Òªº¦×ÖÓÃÓÚÔÚ SQL Óï¾äÖÐÖ¸¶¨Ìõ¼þ£¬ÒÔ¹ýÂ˳öÖª×ãÌض¨±ê×¼µÄ¼Í¼¡£ËüÔÊÐíÄãƾ֤Ìض¨Áлò±í´ïʽµÄÖµÀ´ÏÞÖÆÒª¼ìË÷µÄÊý¾Ý¡£
WHERE Óï¾äµÄÓï·¨£º
SELECT column_list FROM table_name WHERE condition;
µÇ¼ºó¸´ÖÆ
WHERE Ìõ¼þµÄÀàÐÍ£º
µÈÖµÌõ¼þ£º¼ì²éÁÐÖµÊÇ·ñ¼´ÊÇÖ¸¶¨Öµ¡£ÀýÈ磺WHERE age = 25
²»µÈÖµÌõ¼þ£º¼ì²éÁÐÖµÊÇ·ñ²»¼´ÊÇÖ¸¶¨Öµ¡£ÀýÈ磺WHERE age 30
½ÏÁ¿Ìõ¼þ£º½«ÁÐÖµÓëÆäËûÖµ»òÁÐÖµ¾ÙÐнÏÁ¿¡£ÀýÈ磺WHERE salary > 50000
²¼¶ûÌõ¼þ£ºÊ¹Óò¼¶ûÔËËã·û (AND, OR, NOT) ×éºÏ¶à¸öÌõ¼þ¡£ÀýÈ磺WHERE (age > 25) AND (salary > 50000)
¿ÕÖµÌõ¼þ£º¼ì²éÁÐÖµÊÇ·ñΪ NULL »ò NOT NULL¡£ÀýÈ磺WHERE name IS NULL
LIKE Ìõ¼þ£ºÊ¹ÓÃͨÅä·û (% ºÍ _) Æ¥Åä×Ö·û´®ÖµµÄÒ»²¿·Ö¡£ÀýÈ磺WHERE name LIKE ‘%John%’
IN Ìõ¼þ£º¼ì²éÁÐÖµÊÇ·ñ°üÀ¨ÔÚÖ¸¶¨ÖµÁбíÖС£ÀýÈ磺WHERE id IN (1, 2, 3)
BETWEEN Ìõ¼þ£º¼ì²éÁÐÖµÊÇ·ñÔÚÖ¸¶¨¹æÄ£Ö®ÄÚ¡£ÀýÈ磺WHERE age BETWEEN 20 AND 30
ʾÀý£º
ÒÔÏ SQL Óï¾äƾ֤ age ÁеÄÖµ¼ìË÷ÄêËê´óÓÚ 25 ËêµÄËùÓмͼ£º
SELECT * FROM employees WHERE age > 25;
µÇ¼ºó¸´ÖÆ
ʹÓà WHERE Ìõ¼þ¿ÉÒÔÈÃÄã´ÓÊý¾Ý¿â±íÖиßЧµØ¼ìË÷ÇкÏÌض¨±ê×¼µÄÊý¾Ý£¬Õâ¹ØÓÚ¹ýÂ˺ÍÅÌÎÊÊý¾ÝÖÁ¹ØÖ÷Òª¡£
ÒÔÉϾÍÊÇsqlÖÐÓÃʲôÀ´ÌåÏÖÌõ¼þµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡