Problems with MySQL GROUP by

Source: Internet
Author: User

Select  from Group  by  having Count (*>1

Like the above sentence, SQL executes in Oracle, but MySQL does not.

However, be aware that it will only return one piece of data. One of the words here is not the final result but one.

For example, there are 3 data of the same wxno (such as Wxno=test1), with a userid of 101,102,103, and 2 wxno the same data (such as Test2), with a userid of 104,105, respectively.

The data returned after execution is as follows:

101,104.

I found the problem when I cleared the T_wxuser table to repeat the data. After execution, the query found that there were duplicate data, which was thought to be a problem with SQL.

Look at the above line of SQL returned results only to find that this is the case.

One more thing, when you update/delete a table, your from table is not the same.

Like what:

Delete  from where inch (selectfromgroupby havecount(*>  1);

This is not possible, will be an error.

Error when this is the case:

[ERR] 1093-you can ' t specify target table ' T_wxuser ' for update on FROM clause

So, there's no way to add an alias.

Delete  from where inch (Select* fromGroup  Count(*>1) AA);

This situation is not a problem in Oracle.

Problems with MySQL GROUP by

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.