mysqlÖÐfieldÊÇʲôÒâ˼
mysql ÖÐ field Òªº¦×ÖÓÃÓÚÔÚ±íÖвéÕÒÁеÄÐòºÅ£¬Í¨¹ýÖ¸¶¨±í´ïʽºÍÒª½ÏÁ¿µÄÁÐÃû£¬¼´¿É·µ»ØÆ¥ÅäÁеÄË÷Òý£¬²»È»·µ»Ø 0 »ò null£¬³£ÓÃÓÚ¶¯Ì¬ sql ºÍÈ·¶¨ÁÐ˳Ðò¡£
MySQL ÖÐµÄ FIELD
FIELD ÊÇ MySQL ÖеÄÒ»¸öÒªº¦×Ö£¬ÓÃÓÚÔÚ SELECT Óï¾äÖмìË÷±íÖÐÁеÄÐòºÅ£¨Ë÷Òý£©¡£
ÓÃ;
·µ»ØÖ¸¶¨ÁÐÔÚ±íÖеÄË÷Òý¡£
È·¶¨ÁÐÔÚ±íÖеÄλÖá£
ÓÃÓÚ¶¯Ì¬ SQL Óï¾äÖУ¬ÆäÖÐÐèҪƾ֤Ìõ¼þÒýÓÃÌض¨µÄÁС£
Óï·¨
FIELD(expr, col1, col2, ..., coln)
µÇ¼ºó¸´ÖÆ
ÆäÖУº
expr ÊÇÒª¼ìË÷ÆäË÷ÒýµÄ±í´ïʽ»òÁÐÃû¡£
col1, col2, …, coln ÊÇÓÃÓÚÈ·¶¨Ë÷ÒýµÄÁÐÃûµÄÁÐ±í¡£
ʾÀý
ÔÚÃûΪ “employees” µÄ±íÖУ¬»ñÈ¡ “last_name” ÁеÄË÷Òý£º
SELECT FIELD('Smith', last_name) FROM employees;
µÇ¼ºó¸´ÖÆ
˵Ã÷
ÈôÊÇ expr ÓëÈκΠcoln Æ¥Å䣬Ôò·µ»ØÆäË÷Òý¡£
ÈôÊÇ expr ÓëÈκΠcoln ²»Æ¥Å䣬Ôò·µ»Ø 0¡£
ÈôÊÇ expr Ϊ NULL£¬Ôò·µ»Ø NULL¡£
Óŵã
ÔÚ±àд¶¯Ì¬ SQL Óï¾äʱºÜÓÐÓã¬ÕâЩÓï¾äÐèҪƾ֤Ìõ¼þÒýÓÃÌض¨ÁС£
¿ÉÒÔÓÃÀ´È·¶¨±íÖÐÁеÄ˳Ðò¡£
ÌṩÁËÒ»ÖÖ¼òÆÓµÄÒªÁìÀ´¼ìË÷ÁеÄË÷Òý£¬¶øÎÞÐèʹÓÃÖØ´óµÄ×ÓÅÌÎÊ»òÅþÁ¬¡£
×¢ÖØÊÂÏî
FIELD ²»¿ÉÓÃÓÚ GROUP BY »ò ORDER BY ×Ӿ䡣
FIELD »áµ¼ÖÂÌØÁíÍâÊý¾Ý´¦Öóͷ£¿ªÏú£¬Òò´ËÔÚÐèÒª¸ßÐÔÄܵÄÅÌÎÊÖÐÓ¦ÉóÉ÷ʹÓá£
ÒÔÉϾÍÊÇmysqlÖÐfieldÊÇʲôÒâ˼µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡