|
MySQL duplicate data look-up table, for example, now you need to check out the bar code table duplicate records, SQL as follows:
SELECT GUIDE_BARCODE FROM checker_barcode
GROUP BY GUIDE_BARCODE HAVING COUNT (GUIDE_BARCODE)> 1
Enquire now duplicate sql data is out, but generally will write sql might like me to write:
SELECT GUIDE_BARCODE FROM checker_barcode
where COUNT (GUIDE_BARCODE)> 1
GROUP BY GUIDE_BARCODE
The latter condition as having the condition where the query, but when the count as a function of where the query conditions, sql grammar is wrong, because W3School about having a function to introduce the sentence is:
Increase HAVING clause in SQL because, WHERE keyword can not be used with aggregate functions.
That is to say, these five conditions where the function can not be used together, but may be used together check out the desired result and having.
Total function: mysql aggregate categories include five kinds of functions: avg, count, sum, min, max. |
|
|
|