sqlÖÐfromÊÇʲôÒâ˼
from Òªº¦×ÖÓÃÓÚÖ¸¶¨ÒªÅÌÎʵÄÊý¾ÝȪԴ£¨¼´±í£©£¬ÆäÓ﷨Ϊ£ºfrom table_name£¬ÔÚ select Óï¾äÖÐÖ¸¶¨ÒªÅÌÎÊµÄ±í£»ÔÚ join ²Ù×÷ÖÐÖ¸¶¨ÒªÅþÁ¬µÄ±í£»ÔÚ×ÓÅÌÎÊÖÐÖ¸¶¨ÒªÅÌÎʵÄ×Ó±í¡£
SQL ÖÐµÄ FROM Òªº¦×Ö
FROM Òªº¦×ÖµÄ×÷ÓÃ
FROM Òªº¦×ÖÓÃÓÚÖ¸¶¨ÒªÅÌÎʵÄÊý¾ÝȪԴ£¬¼´´ÓÄĸö±íÖÐÌáÈ¡Êý¾Ý¡£
FROM Òªº¦×ÖµÄÓï·¨
FROM table_name
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬table_name ÊÇÒªÅÌÎʵıíÃû¡£
FROM Òªº¦×ÖµÄÓ÷¨
FROM Òªº¦×Öͨ³£ÓÃÔÚ SELECT Óï¾äÖУ¬ÓÃÓÚÖ¸¶¨ÒªÅÌÎÊµÄ±í¡£ÀýÈ磺
SELECT * FROM customers;
µÇ¼ºó¸´ÖÆ
´ËÅÌÎʽ«´ÓÃûΪ customers µÄ±íÖÐÑ¡ÔñËùÓÐÐкÍÁС£
JOIN ²Ù×÷ÖÐµÄ FROM Òªº¦×Ö
FROM Òªº¦×ÖÒ²¿ÉÒÔÓÃÔÚ JOIN ²Ù×÷ÖУ¬ÓÃÓÚÖ¸¶¨ÒªÅþÁ¬µÄ±í¡£ÀýÈ磺
SELECT * FROM customers INNER JOIN orders ON customers.id = orders.customer_id;
µÇ¼ºó¸´ÖÆ
´ËÅÌÎʽ«ÅþÁ¬ customers ±íºÍ orders ±í£¬²¢½« customers ±íÖÐµÄ id ÁÐÓë orders ±íÖÐµÄ customer_id ö¾ÙÐÐÆ¥Åä¡£
×ÓÅÌÎÊÖÐµÄ FROM Òªº¦×Ö
FROM Òªº¦×ÖÒ²¿ÉÒÔÓÃÔÚ×ÓÅÌÎÊÖУ¬ÓÃÓÚÖ¸¶¨ÒªÅÌÎʵÄ×Ó±í¡£ÀýÈ磺
SELECT * FROM ( SELECT * FROM customers WHERE city = 'New York' );
µÇ¼ºó¸´ÖÆ
´ËÅÌÎʽ«´Ó customers ±íÖÐÑ¡ÔñËùÓÐÖª×ã city Áм´ÊÇ New York µÄÐС£
ÒÔÉϾÍÊÇsqlÖÐfromÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡