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