Converts a subquery to a join query.

Source: Internet
Author: User
The original subquery SELECTCOUNT (*) interval & #039; 1 & #039; andcreatetime & amp; gt; 1413533130andarea_codein (,) andmember_idin (original...

Select count (*) AS tp_count FROM sdb_ B2C _orders WHERE pay_status = '1' and createtime> 1413533130 and area_code in) and member_id in (select member_id from sdb_invite_invite where in_member_id = 14273 or in_member_id = 13742 or in_member_id = 14299) LIMIT 1

The execution result is22

Use connection query instead of the preceding subquery

Select count (*) AS tp_count FROM sdb_ B2C _orders AS bo INNER JOIN sdb_invite_invite AS ii ON bo. member_id = ii. in_member_id WHERE bo. pay_status = '1' AND bo. area_code IN (1030,1031, 1032,1033) AND bo. createtime & gt; 1413533130 AND ii. in_member_id IN (14273,13742, 14299)

The execution result is131

Reply content:

Original subquery

Select count (*) AS tp_count FROM sdb_ B2C _orders WHERE pay_status = '1' and createtime> 1413533130 and area_code in) and member_id in (select member_id from sdb_invite_invite where in_member_id = 14273 or in_member_id = 13742 or in_member_id = 14299) LIMIT 1

The execution result is22

Use connection query instead of the preceding subquery

Select count (*) AS tp_count FROM sdb_ B2C _orders AS bo INNER JOIN sdb_invite_invite AS ii ON bo. member_id = ii. in_member_id WHERE bo. pay_status = '1' AND bo. area_code IN (1030,1031, 1032,1033) AND bo. createtime & gt; 1413533130 AND ii. in_member_id IN (14273,13742, 14299)

The execution result is131

Repeated sdb_invite_invite.in_member_id records

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.