Nice mysql Union table multi-table query bitsCN.com
Good mysql multi-table query
For mysql multi-table queries, you can directly select * from tablea as a, tableb. as B where. cc = B. cc. today, I will share a novel way of writing, and the execution efficiency of hundreds of thousands of data is quite fast. Here are some statements for multi-table queries:
SQL code
# Information about QQ invitations for deleting illegal credit data from Tbl_User
Delete from Tbl_User where FQQ IN
(Select FDesQQ from Tbl_InviteHistory where FSrcQQ IN
(Select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '20180101' and FStrategy = '4 '))
# Delete QQ information of illegal credit data from Tbl_User
Delete from Tbl_User where FQQ IN
(Select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '20180101' and FStrategy = '4 ')
# Delete the invitation records for all invalid points in Tbl_InviteHistory
Delete from Tbl_InviteHistory where FSrcQQ IN
(Select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '20180101' and FStrategy = '4 ')
# Delete the total points of invalid points in Tbl_Score
Delete from Tbl_Score where FQQ IN
(Select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '20180101' and FStrategy = '4 ')
# Delete invalid points in Tbl_ScoreDetail
Delete from Tbl_ScoreDetail where FScore> '2013' and FStrategy = '4'
# Delete users without Tbl_User in the Tbl_Score table
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)
// Query the user list with a redemption code greater than 20
Select fqq, FCode, FApplyTime FROM Tbl_Code where FQQ in (SELECT. fqq from (select count (*) as num, fqq from 'tbl _ code' group by fqq having num> 20) as a) and FStatus = '1'
BitsCN.com