Turn subqueries into a list query problem

Source: Internet
Author: User
SELECT * FROM (select A.video_name Name,a.vid,a.pos,a.pic,a.definition,b.app_code,a.strength,a.ad_mark from Access_ App_video A
Left JOIN Access_app b in A.app_id=b.id WHERE tag_interest=2 and App_id=1 and A.ad_mark=1 and A.status=0 ORDER by ABS (tag_ sex-16), ABS (tag_figure-10)) AA
ORDER by Aa.strength DESC LIMIT 0,12

How the subquery changes to a linked table query


Reply to discussion (solution)

SELECT a.video_name Name,a.vid,a.pos,a.pic,a.definition,b.app_code,a.strength,a.ad_mark from  access_app_video A left joins Access_app B on A.app_id=b.id  WHERE tag_interest=2 and App_id=1 and A.ad_mark=1 and a.status=0   ORDER b Y A.strength, ABS (TAG_SEX-16), ABS (TAG_FIGURE-10) DESC  LIMIT 0,12

Thank the 2 floor answer, but this write, the results of the search and the original results are different, the original SQL means first according to ABS (TAG_SEX-16), ABS (tag_figure-10) sort
Then sorted by a.strength, the SQL on the 2 floor changed the collation.

#2


Is the statement not able to use a linked table query?

The end result is to press a.strength descending, when a.strength is simultaneously pressed ABS (TAG_SEX-16), ABS (TAG_FIGURE-10) ascending
Of course, when ABS (TAG_SEX-16), ABS (TAG_FIGURE-10) have multiple sets of the same value, the results will be slightly different

That's why the writer wrote that.

5


Is this, now is to use ORM to write SQL, always thought that all sub-queries can be replaced with a table query, just want to change the query into a table query, think, even the table query seems to solve, can only continue to write
  • 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.