您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

不错的mysql联表多表查询_MySQL

2024/4/29 2:57:43发布19次查看
bitscn.com
不错的mysql联表多表查询
mysql联表多表查询,以前查询的时候,可以直接select * from tablea as a ,tableb.as b where a.cc=b.cc.今天分享一个新奇的写法,而且对于百w数据执行效率可是相当的快,下面分享一下联表多表查询的几个语句:
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')
#在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'
#删除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'
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product