mysqlÖÐasÊÇʲôÒâ˼
mysql ÖÐ as ÓÃÓÚ½¨Éè±í»òÁÐÓÖÃû£¬ÒÔ¼ò»¯ÅÌÎÊÖбí»òÁеÄÒýÓ㺱íÓÖÃû£ºÔÚÒ»¸öÅÌÎÊÖÐʹÓöà¸ö±íʱ£¬Ö¸¶¨±íÓÖÃû£¬ÒÔ±ãÒýÓñíÖеÄÁиüÀû±ã¡£ÁÐÓÖÃû£ºÖ¸¶¨ÁÐÓÖÃû£¬ÒÔ±ãÔÚÅÌÎÊЧ¹ûÖÐʹÓòî±ðµÄÃû³Æ»òÓÖÃû¡£
MySQL ÖÐ AS µÄ¼ÄÒå
AS ÔÚ MySQL ÖÐÊÇÒ»¸ö±£´æÒªº¦×Ö£¬ÓÃÓÚ½¨Éè±íÓÖÃû»òÁÐÓÖÃû¡£
±íÓÖÃû
µ±ÔÚÒ»¸öÅÌÎÊÖÐʹÓöà¸ö±íʱ£¬¿ÉÒÔʹÓà AS Ϊ±íÖ¸¶¨ÓÖÃû£¬ÒÔʹÒýÓñíÖеÄÁÐʱԽ·¢Àû±ã¡£ÀýÈ磺
SELECT * FROM users AS u, orders AS o WHERE u.id = o.user_id;
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬±í users ºÍ orders ±»Ö¸¶¨ÁËÓÖÃû u ºÍ o¡£ÕâÑù£¬¾Í¿ÉÒÔʹÓÃÓÖÃûÀ´ÒýÓñíÖеÄÁУ¬ÀýÈç u.id ºÍ o.user_id¡£
ÁÐÓÖÃû
Ò²¿ÉÒÔʹÓà AS ΪÁÐÖ¸¶¨ÓÖÃû£¬ÒÔ±ãÔÚÅÌÎÊЧ¹ûÖÐʹÓòî±ðµÄÃû³Æ»òÓÖÃû¡£ÀýÈ磺
SELECT name AS full_name FROM users;
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬name Áб»Ö¸¶¨ÁËÓÖÃû full_name¡£ÔÚÅÌÎÊЧ¹ûÖУ¬name Áн«ÏÔʾΪ full_name¡£
Ó÷¨
ʹÓà AS ½¨ÉèÓÖÃûµÄÓï·¨ÈçÏ£º
AS
µÇ¼ºó¸´ÖÆ
ÆäÖУº
ÊÇÒª½¨ÉèµÄÓÖÃû¡£
ÊÇҪΪÆ佨ÉèÓÖÃûµÄ±í»òÁеÄÔʼÃû³Æ¡£
Óŵã
ʹÓÃÓÖÃû¿ÉÒÔʹÅÌÎÊÔ½·¢ÈÝÒ×Ã÷È·ºÍά»¤£¬ÓÈÆäÊǵ±ÔÚÒ»¸öÅÌÎÊÖÐʹÓöà¸ö±í»òÁÐʱ¡£ÓÖÃû¿ÉÒÔ×ÊÖúÏû³ýÆçÒ壬²¢Ê¹ÅÌÎÊЧ¹ûÔ½·¢Ö±¹Û¡£
ÒÔÉϾÍÊÇmysqlÖÐasÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡