程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 復雜的sql語句join的使用(left join,right join)

復雜的sql語句join的使用(left join,right join)

編輯:MySQL綜合教程

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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved