我试图在
MySQL语句中检查2个空变量,但我似乎可以得到相当正确的语法.这是我现在所在,它不断给我一个错误.任何人都可以告诉我如何正确地做到这一点?
SELECT threads,userid,username,usergroupid FROM " . TABLE_PREFIX . "user WHERE " . iif(!empty($exuserids),"AND userid NOT IN ($exuserids)") . " " . iif(!empty($exgroups),"AND usergroupid NOT IN ($exgroups)") . " ORDER BY threads DESC LIMIT 1
使用:
原文链接:https://www.f2er.com/php/140199.htmlSELECT threads,usergroupid FROM " . TABLE_PREFIX . "user WHERE 1 = 1 " . iif(!empty($exuserids),"AND usergroupid NOT IN ($exgroups)") . " ORDER BY threads DESC LIMIT 1
在指定“AND …”之前,需要有一个WHERE子句 – 1 = 1将被优化.这是用于动态sql以使WHERE子句连接更容易的技巧.