I have the following table:
n1|n2|n3|n4|n5
1| 5| 4| 7|26
26|80|75| 1|10
5| 3| 2| 1|4
45|26| 1| 3|66
I'm trying to get the number of rows in which two or more specified values appear. In the above table, for example, 26 and 1 appear in 3 rows.
Is there a fast way to do this in mySQL or should I build some function in PHP?
Thank you very much for your help
The SQL COUNT( ) function is used to return the number of rows in a table. It is used with the Select( ) statement.
To counts all of the rows in a table, whether they contain NULL values or not, use COUNT(*). That form of the COUNT() function basically returns the number of rows in a result set returned by a SELECT statement.
SELECT COUNT(*) FROM your_table
WHERE 1 IN (n1,n2,n3,n4,n5) AND 26 IN (n1,n2,n3,n4,n5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With