Php mysql语句中的条件
我正在尝试在mysql查询中写入一个条件:Php mysql语句中的条件,php,mysql,Php,Mysql,我正在尝试在mysql查询中写入一个条件: SELECT g.* FROM groups AS g JOIN users AS u ON u.user_posts >= g.post_min AND u.user_posts <= g.post_max AND u.points >= g.point_min AND u.points <= g.
SELECT g.* FROM groups AS g
JOIN users AS u
ON u.user_posts >= g.post_min
AND u.user_posts <= g.post_max
AND u.points >= g.point_min
AND u.points <= g.point_max
AND u.uid = "'.$uid.'"
从组中选择g.*作为g
以u的身份加入用户
在u.user_posts>=g.post_min上
和u.user_posts=g.point_min
和u.points$sql='选择g.id,g.point\u金额
来自组作为g
以u的身份加入用户
在u.user_posts>=g.post_min上
和(u.user_posts=g.point_min
和(u.points用OR连接它们;跳过条件为真,或者术语不能跳过:
(g.post_max = 0) OR (u.user_posts <= g.post_max)
(g.point_max = 0) OR (u.points <= g.point_max)
(g.post\u max=0)或(u.user\u posts)可能有帮助
(g.post_max = 0) OR (u.user_posts <= g.post_max)
(g.point_max = 0) OR (u.points <= g.point_max)
$sql = 'SELECT g.id,g.point_amount
FROM groups AS g
JOIN users AS u
ON u.user_posts >= g.post_min
AND u.points >= g.point_min
AND ((g.post_max = 0) OR (u.user_posts <= g.post_max))
AND ((g.point_max = 0) OR (u.points <= g.point_max))
AND u.uid = "'.$uid.'"
LIMIT 1';