sqlÖÐÌåÏÖÅÌÎʵÄÏÂÁîÊÇʲô
ÔÚ sql ÖУ¬Ö´ÐÐÅÌÎʵÄÏÂÁîÊÇ select¡£select Óï¾äµÄÓï·¨°üÀ¨ÒÔÏÂ×é³É²¿·Ö£º1. select : Ö¸¶¨Òª¼ìË÷µÄÁУ»2. from : Ö¸¶¨¼ìË÷Êý¾ÝµÄ±í£»3. [where ]: ɸѡÅÌÎÊЧ¹ûµÄÐУ»4. [group by ]: ¶ÔЧ¹û·Ö×飻5. [having ]: ¶Ô·Ö×éЧ¹ûɸѡ£»6. [order
SQL ÖÐÌåÏÖÅÌÎʵÄÏÂÁîÊÇʲô£¿
ÔÚ SQL ÖУ¬ÓÃÓÚÖ´ÐÐÅÌÎʵÄÏÂÁîÊÇ SELECT¡£
SELECT Óï¾äµÄÓï·¨ÈçÏ£º
SELECT <column_list> FROM <table_name> [WHERE <condition>] [GROUP BY <column_list>] [HAVING <condition>] [ORDER BY <column_list>]</column_list></condition></column_list></condition></table_name></column_list>
µÇ¼ºó¸´ÖÆ
SELECT Óï¾äµÄ×é³É²¿·Ö£º
SELECT £º Ö¸¶¨Òª´Ó±íÖмìË÷µÄÁС£
FROM £º Ö¸¶¨Òª´ÓÆä¼ìË÷Êý¾ÝµÄ±í¡£
WHERE £º £¨¿ÉÑ¡£©Ö¸¶¨ÒªÉ¸Ñ¡ÅÌÎÊЧ¹ûµÄÐС£
GROUP BY £º £¨¿ÉÑ¡£©Ö¸¶¨ÓÃÓÚ¶ÔЧ¹û¾ÙÐзÖ×éµÄÁС£
HAVING £º £¨¿ÉÑ¡£©Ö¸¶¨¶Ô·Ö×éЧ¹û¾ÙÐÐɸѡµÄÌõ¼þ¡£
ORDER BY £º £¨¿ÉÑ¡£©Ö¸¶¨ÓÃÓÚ¶ÔЧ¹ûÅÅÐòµÄÁС£
¾ÙÀý£º
ÒÔÏ SQL Óï¾ä¿É´Ó “students” ±íÖмìË÷ËùÓÐѧÉúµÄÐÕÃûºÍÄêË꣺
SELECT name, age FROM students;
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇsqlÖÐÌåÏÖÅÌÎʵÄÏÂÁîÊÇʲôµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡