thinkphpÔõÑùÅÌÎÊÊý¾Ý¿âÖеÄÖظ´Êý¾Ý
Ê×ÏÈ£¬ÈÃÎÒÃǼÙÉèÄãÒѾÓÐÁËÒ»¸öÊý¾Ý¿â±í¡£¼ÙÉèÓÐÒ»ÕÅÃûΪ¡°students¡±µÄ±í¸ñ£¬ÆäÖаüÀ¨ÒÔÏÂÈý¸ö×ֶΣºid¡¢nameºÍage¡£ÏÖÔÚ£¬ÎÒÃÇÏëÒªÕÒ³öÄÄЩѧÉúµÄÐÕÃûÔÚÊý¾Ý¿âÖÐÊÇÖظ´µÄ¡£
ʹÓÃThinkPHP£¬¿ÉÒÔÇáËɵشӱíÖÐÅÌÎÊÖظ´µÄÊý¾Ý¡£ÏÂÃæÊÇÒ»¸öÅÌÎÊÖظ´Êý¾ÝµÄʾÀý´úÂ룺
$students = Db::name('students')->field('name, count(name) as count')->group('name')->having('count>1')->select();
µÇ¼ºó¸´ÖÆ
ÈÃÎÒÃÇÖðÒ»Ú¹ÊÍÕâ¸ö´úÂëµÄÿһ²¿·Ö¡£
Ê×ÏÈ£¬ÎÒÃÇʹÓÃDbÀàµÄ³£Á¿ name ÒªÁì»ñµÃstudents±íµÄÃû³Æ¡£ÔÚÕâ¸öÀý×ÓÖУ¬ÎÒÃÇʹÓÃÁË field ÒªÁ콫Á½¸ö×ֶηµ»Øµ½Ð§¹û¼¯ÖУºÐÕÃûºÍ¼ÆÊý¡£count(name) º¯ÊýÓÃÓÚ½«Í¬ÃûµÄЧ¹û¼ÆÊý¡£ÎÒÃǽ«Ð§¹ûƾ֤ÐÕÃû·Ö×飬ʹÓà having º¯ÊýÀ´¹ýÂ˼ÆÊý´óÓÚ1µÄЧ¹û¡£×îºó£¬ÎÒÃÇʹÓà select º¯Êý·µ»ØÊý¾Ý¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÎÒÃÇ¿ÉÒÔ²éÕÒѧÉú±íÖÐÖظ´µÄÐÕÃû£¬²¢ÅÌËãÿ¸öÖظ´Ïî·ºÆðµÄ´ÎÊý¡£ÎÒÃǽ«Äܹ»¿ìËÙ¶¨Î»µ½ÎÒÃÇÐèÒª²éÕÒµÄÊý¾Ý²¢¾ÙÐнøÒ»²½´¦Àí¡£
¿ÉÊÇ£¬ÕâÖÖÒªÁì¿ÉÄܱ£´æһЩÏÞÖÆ¡£Ê×ÏÈ£¬ÎÒÃÇ¿ÉÄÜÐèÒª¸ü¶àµÄÊý¾ÝÀ´È·¶¨Öظ´ÏÓÉÓÚÕâ¸öÒªÁìÖ»ÄÜÕÒµ½Öظ´ÏîµÄÃû³Æ£¬¶ø²»¿ÉÕÒµ½ÆäËûÁÐÖеÄÖظ´Ïî¡£ÁíÍ⣬ÕâÖÖÒªÁìÐèҪɨÃèÕû¸ö±íÒÔ²éÕÒÖظ´Ï¿ÉÄܻᵼÖÂÐÔÄÜÎÊÌâ¡£
Òò´Ë£¬ÔÚÏÖÕæÏླÖУ¬ÎÒÃÇ¿ÉÒÔ½ÓÄɸüÓÐÓÃÂʵÄÅÌÎÊ·½·¨À´Ñ°ÕÒÖظ´Êý¾Ý¡£Êý¾Ý¿âÉè¼Æ½ÓÄÉË÷ÒýºÍ¸´ºÏ¼ü¿É´ó·ùÌáÉýÅÌÎÊЧÂÊ£¬´Ó¶ø¿ìËÙ¶¨Î»µ½Öظ´Ïî¡£
ÒÔÉϾÍÊÇthinkphpÔõÑùÅÌÎÊÊý¾Ý¿âÖеÄÖظ´Êý¾ÝµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡