程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 不錯的mysql聯表多表查詢

不錯的mysql聯表多表查詢

編輯:MySQL綜合教程

不錯的mysql聯表多表查詢   mysql聯表多表查詢,以前查詢的時候,可以直接select * from tablea as a ,tableb.as b where a.cc=b.cc.今天分享一個新奇的寫法,而且對於百W數據執行效率可是相當的快,下面分享一下聯表多表查詢的幾個語句:    www.2cto.com   SQL代碼 #在Tbl_User中刪除非法積分數據的QQ的邀請好友QQ資料   delete from Tbl_User where FQQ IN   (select FDesQQ from Tbl_InviteHistory where FSrcQQ IN   (select DISTINCT(FSrcQQ) from Tbl_ScoreDetail where FScore>'250' and FStrategy='4'))      #在Tbl_User中刪除非法積分數據的QQ資料   delete from Tbl_User where FQQ IN   (select DISTINCT(FSrcQQ) from Tbl_ScoreDetail where FScore>'250' and FStrategy='4')      #在Tbl_InviteHistory中刪除所有非法積分數據的邀請記錄   delete from Tbl_InviteHistory where FSrcQQ IN   (select DISTINCT(FSrcQQ) from Tbl_ScoreDetail where FScore>'250' and FStrategy='4')       www.2cto.com   #在Tbl_Score中刪除非法積分數據的總積分   delete from Tbl_Score where FQQ IN   (select DISTINCT(FSrcQQ) from Tbl_ScoreDetail where FScore>'250' and FStrategy='4')      #在Tbl_ScoreDetail中刪除非法積分明細   delete from Tbl_ScoreDetail where FScore>'250' and FStrategy='4'       www.2cto.com   #刪除Tbl_Score表裡沒有Tbl_User的用戶   delete from Tbl_Score where FQQ not IN (select FQQ from Tbl_User)   delete from Tbl_ScoreDetail where FSrcQQ not IN (select FQQ from Tbl_User)    //查兌換碼大於20的用戶明細表 SELECT FQQ,FCode,FApplyTime FROM Tbl_Code where FQQ in (SELECT a.FQQ FROM (SELECT COUNT(*) as num,FQQ FROM `Tbl_Code` GROUP BY FQQ HAVING num>20) as a) and FStatus='1'   

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