Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mysql语句中的条件_Php_Mysql - Fatal编程技术网

Php 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.

我正在尝试在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.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';