我真的不知道如何在这个SQL查询中使用“Where”条件
我应该使用这样的东西:
其中rules_id!= 6
* rules_id = 6 =>禁止用户规则
$stmt = $db_con->prepare("
select * from users
JOIN rules
On users.rules_id = rules.rules_id
order by rand() limit 1
");
答案 0 :(得分:1)
只需将其放在order by
$stmt = $db_con->prepare("select * from users
JOIN rules On users.rules_id = rules.rules_id
where users.rules_id != 6
order by rand()
limit 1");