Is there a problem with the way SQL statements are written?

Source: Internet
Author: User
Is there a problem with the way SQL statements are written?
SELECT * FROM [select * from Xf_art where flag=3 order by add_time Desc] A, (SELECT ID userid,username from XF_USR where FL ag!=9) u where a.xfuid=u.userid order BY a.add_time Desc

The above SQL statement is a colleague I have left to write, run normal, but how to feel a bit awkward, SQL statement Such writing is there a problem? Where is the problem (I can't say it now, so I'll ask you)

------Solution--------------------
The statement is no problem, the efficiency may have some problems, check with explain.
SQL Code
Explain select * FROM [select * from Xf_art where flag=3 order by add_time Desc] A, (SELECT ID userid,username from XF_USR where flag!=9) u where a.xfuid=u.userid order BY a.add_time Desc
------Solution--------------------
No problem, from a performance point of view, the first order by add_time Desc can be unwanted.
------Solution--------------------
Such SQL statements can be run without problems, but the efficiency of execution is further modified.

He is the select * from Table A, table U where A.xfuid=u.userid;
  • 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.