sqlÖв»¼´ÊÇij¸öÌõ¼þÔõôд³öÀ´
ÔÚ sql ÖУ¬”” ÔËËã·ûÓÃÓÚÌåÏÖ¡°²»¼´ÊÇ¡±Ä³¸öÌõ¼þ£¬Ó﷨Ϊ£ºselect from table_name where column_name value¡£ÀýÈ磺²éÕÒ name ²»¼´ÊÇ “john doe” µÄ¿Í»§£ºselect from customers where name ‘john doe’£»²éÕÒ price ²»¼´ÊÇ 100 µÄ²úÆ·£ºselect * from products where price 100¡£
ÔõÑùʹÓà SQL ÌåÏÖ¡°²»¼´ÊÇ¡±Ä³¸öÌõ¼þ
ÔÚ SQL ÖУ¬Ê¹Óà “” ÔËËã·ûÌåÏÖ¡°²»¼´ÊÇ¡±¡£
Óï·¨£º
SELECT * FROM table_name WHERE column_name value
µÇ¼ºó¸´ÖÆ
ÒÔÏÂʾÀýÑÝʾÔõÑùʹÓà “” ÔËËã·û£º
-- ²éÕÒËùÓÐÐÕÃû²»Îª "John Doe" µÄ¿Í»§ SELECT * FROM customers WHERE name 'John Doe'; -- ²éÕÒËùÓмÛÇ®²»Îª 100 µÄ²úÆ· SELECT * FROM products WHERE price 100; -- ²éÕÒËùÓж©µ¥ÈÕÆÚ²»Îª "2023-03-08" µÄ¶©µ¥ SELECT * FROM orders WHERE order_date '2023-03-08';
µÇ¼ºó¸´ÖÆ
ÆäËû×¢ÖØÊÂÏ
“” ÔËËã·û»¹¿ÉÓÃÓÚ½ÏÁ¿ NULL Öµ¡£ÀýÈ磬ÒÔÏÂÅÌÎÊ·µ»ØËùÓоßÓÐ·Ç NULL Ãû³ÆµÄ¿Í»§£º
SELECT * FROM customers WHERE name NULL;
µÇ¼ºó¸´ÖÆ
ʹÓà “” ÔËËã·ûʱ£¬ÇëÈ·±£Êý¾ÝÀàÐÍÆ¥Åä¡£ÀýÈ磬ÈôÊÇ “column_name” ÊÇÒ»¸ö×Ö·û´®£¬Ôò “value” Ò²±ØÐèÊÇÒ»¸ö×Ö·û´®¡£
ÒÔÉϾÍÊÇsqlÖв»¼´ÊÇij¸öÌõ¼þÔõôд³öÀ´µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡