Good mysql multi-Table query

Source: Internet
Author: User

Good mysql Union table multi-Table query. In previous 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: www.2cto.com SQL code # Invite friends to delete QQ information from Tbl_User where FQQ IN (select FDesQQ from Tbl_InviteHistory where FSrcQQ IN (select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '20140901' and FStrategy = '4') # delete the QQ data of illegal points from Tbl_User where fqq in (select DISTINCT (FSrcQQ) from orders where FScore> '200' and FStrategy = '4') # delete the invitation record for deleting all illegal points IN Tbl_InviteHistory from Tbl_InviteHistory where FSrcQQ IN (select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '20140901' and FStrategy = '4') www.2cto.com # delete the total points of illegal points IN Tbl_Score from Tbl_Score where fqq in (select DISTINCT (FSrcQQ) from Tbl_ScoreDetail where FScore> '2013' and FStrategy = '4 ') # delete invalid credit details IN detail delete from Tbl_ScoreDetail where FScore> '123' and FStrategy = '4' www.2cto.com # delete a user 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) // 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'

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.