sqlÖÐÅÌÎÊÏÂÁîµÄÒªº¦×ÖÊÇ
sql ÖÐÅÌÎÊÊý¾ÝµÄÏÂÁîÒªº¦×ÖÊÇ select£¬ËüÓÃÓÚ´ÓÊý¾Ý¿â±íÖÐÌáÈ¡Ìض¨Áлò¼Í¼¡£select Óï¾ä½á¹¹°üÀ¨£ºselect [distinct] from [where ][order by ][limit ]
SQL ÖÐÅÌÎÊÏÂÁîµÄÒªº¦×Ö£ºSELECT
SQL ÖÐÅÌÎÊÊý¾ÝµÄÏÂÁîÒªº¦×ÖÊÇ SELECT¡£ËüÓÃÓÚ´ÓÊý¾Ý¿â±íÖÐÌáÈ¡Ìض¨Áлò¼Í¼¡£
SELECT Óï¾ä½á¹¹£º
SELECT [DISTINCT] FROM [WHERE ] [ORDER BY ] [LIMIT ]
µÇ¼ºó¸´ÖÆ
SELECT Óï¾äÒªËØ£º
DISTINCT£ºÓÃÓÚɨ³ýÖظ´¼Í¼¡£
ÒªÌáÈ¡µÄÁÐÃû£ºÖ¸¶¨Òª´Ó±íÖлñÈ¡µÄÁС£
FROM£ºÖ¸¶¨ÒªÅÌÎÊµÄ±í¡£
WHERE£ºÖ¸¶¨¹ýÂËÌõ¼þ£¬ÓÃÓÚɸѡ³öÇкÏÌض¨Ìõ¼þµÄ¼Í¼¡£
ORDER BY£ºÖ¸¶¨¶ÔЧ¹û¾ÙÐÐÅÅÐòµÄÁС£
LIMIT£ºÖ¸¶¨Òª·µ»ØµÄ¼Í¼Êý¡£
ʾÀý£º
ÒÔÏÂÓï¾ä´Ó Customers ±íÖÐÅÌÎÊËùÓпͻ§µÄÐÕÃûºÍµç×ÓÓʼþµØµã£º
SELECT Name, Email FROM Customers;
µÇ¼ºó¸´ÖÆ
ÒÔÏÂÓï¾ä´Ó Products ±íÖÐÅÌÎʼÛÇ®´óÓÚ 100 µÄ²úÆ·Ãû³ÆºÍ¼ÛÇ®£º
SELECT Name, Price FROM Products WHERE Price > 100;
µÇ¼ºó¸´ÖÆ
ÒÔÏÂÓï¾ä´Ó Orders ±íÖÐÅÌÎÊÒÑÍù 30 ÌìÄÚµÄËùÓж©µ¥£¬²¢°´ÈÕÆÚ½µÐòÅÅÐò£º
SELECT * FROM Orders WHERE OrderDate >= DATE('now', '-30 days') ORDER BY OrderDate DESC;
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇsqlÖÐÅÌÎÊÏÂÁîµÄÒªº¦×ÖÊǵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡