ÔÚsqlÖÐasʲôÒâ˼
as ÔÚ sql ÖзÖÅɱí´ïʽ¡¢×ÓÅÌÎÊ»ò±íµÄÓÖÃû£¬Ê¹ÖØ´óÅÌÎÊЧ¹ûÒ×ÓÚÃ÷È·¡£ÓÖÃûÓ﷨Ϊ£ºselect as from £¬ÆäÖÐ ¿ÉÒÔÊÇÁС¢±í´ïʽ»ò×ÓÅÌÎÊ£¬ Ϊ·ÖÅɵÄÓÖÃû¡£Óŵã°üÀ¨Ìá¸ß¿É¶ÁÐÔ¡¢ïÔÌÖظ´¡¢Ö§³ÖÖØ´ó±í´ïʽºÍ×èÖ¹ÃüÃû³åÍ»¡£
SQL ÖÐµÄ AS
ʲôÊÇ AS£¿
ÔÚ SQL ÖУ¬AS ÓÃÓÚ½«Ò»¸öÌåÃû·ÖÅɸøÒ»¸ö±í´ïʽ¡¢×ÓÅÌÎÊ»ò±í¡£ËüÔÊÐí¿ª·¢ÕßΪÖØ´óÅÌÎʵÄЧ¹û»ò×ÓÅÌÎʽ¨Éè¸üÒ×ÓÚÃ÷È·µÄÃû³Æ¡£
ÔõÑùʹÓà AS£¿
ʹÓà AS µÄÓï·¨ÈçÏ£º
SELECT <expression> AS <alias> FROM <table_name>;</table_name></alias></expression>
µÇ¼ºó¸´ÖÆ
ÆäÖУº
ÌåÏÖÄãÏ£Íû·ÖÅÉÓÖÃûµÄÖµ£¬Ëü¿ÉÒÔÊÇ£º
µ¥¸öÁлò×Ö¶Î
±í¸ñ±í´ïʽ
×ÓÅÌÎÊ
ÊÇ·ÖÅɸø±í´ïʽµÄÓÖÃû£¬Ëüͨ³£ÊÇÒ»¸ö¸ü¾ßÐÎòÐÔµÄÃû³Æ¡£
ʾÀý£º
½« customer_name ÁзÖÅÉΪÓÖÃû name£º
SELECT customer_name AS name FROM customers;
µÇ¼ºó¸´ÖÆ
ÏÖÔÚ£¬Äú¿ÉÒÔʹÓÃÓÖÃû name ¶ø²»ÊÇ customer_name ÒýÓÃÁУº
SELECT name, address FROM customers;
µÇ¼ºó¸´ÖÆ
Óŵ㣺
ʹÓà AS ÌṩÁËÒÔÏÂÓŵ㣺
Ìá¸ß¿É¶ÁÐÔ£ºÓÖÃûʹÅÌÎʸüÈÝÒ×Ã÷È·ºÍά»¤¡£
ïÔÌÖظ´£ºÎÞÐèÖظ´¼üÈë±í»òÁÐÃû£¬´Ó¶øïÔÌ´úÂëÈßÓà¡£
Ö§³Ö×ÓÅÌÎʺÍÖØ´ó±í´ïʽ£ºAS ¿ÉÒÔ½«ÓÖÃû·ÖÅɸø×ÓÅÌÎÊ»òÖØ´ó±í´ïʽ£¬´Ó¶øʹÆäÒ×ÓÚÒýÓá£
×èÖ¹ÃüÃû³åÍ»£ºµ±¶à¸ö±í»òÁоßÓÐÏàͬÃû³Æʱ£¬AS ¿ÉÒÔ×ÊÖú×èÖ¹ÃüÃû³åÍ»¡£
ÒÔÉϾÍÊÇÔÚsqlÖÐasʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡