复杂的sql语句join的使用(left join,right join)
来源:未知 责任编辑:责任编辑 发表时间:2014-01-26 22:00 点击:次
SELECT u.*,count(u.id) AS sum
02
FROM user AS u
03
LEFT JOIN post AS p
04
ON p.user_id = u.id
05
RIGHT JOIN user_has_group as up
06
ON up.user_id = u.id
07
RIGHT JOIN user_has_email as ue
08
ON ue.user_id = u.id
09
WHERE u.username != ''
10
AND up.group_id = {$args['groupid']}
11
AND ue.email = '{$args['useremail']}'
12
GROUP BY u.id ORDER BY u.id desc
02
FROM user AS u
03
LEFT JOIN post AS p
04
ON p.user_id = u.id
05
RIGHT JOIN user_has_group as up
06
ON up.user_id = u.id
07
RIGHT JOIN user_has_email as ue
08
ON ue.user_id = u.id
09
WHERE u.username != ''
10
AND up.group_id = {$args['groupid']}
11
AND ue.email = '{$args['useremail']}'
12
GROUP BY u.id ORDER BY u.id desc
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>