MySQL executes count error invalid use of group function

Source: Internet
Author: User

Associating two table counts with MySQL SQL statements an error occurred in the number of occurrences of a field: Invalid use of the group function, there is a problem finding the usage of the Count function, which later solves the problem. The wrong syntax for SQL statements is this:

The code is as follows Copy Code


UPDATE V9_keyword as a left JOIN V9_keyword_data as B
On A.id=b.tagid
Set A.videonum=count (B.tagid)
WHERE A.id=b.tagid;

Resolve invalid use of group function error

The third line of Count (B.tagid) has an error: Invalid use of the group function. Translation of Chinese is the incorrect use of collection methods. That is to say, count is a problem, after several modifications, the following SQL is OK.

The code is as follows Copy Code
UPDATE V9_keyword as a left JOIN V9_keyword_data as B
On A.id=b.tagid
Set a.videonum= (SELECT COUNT (tagid) from V9_keyword_data where tagid=a.id)
WHERE A.id=b.tagid;

The first example of the count designation is unknown, and the second example clearly indicates the condition

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.