select COUNT(Id) AS Total
from `euro`
where (N1 = $i or N2 = $i or N3 = $i or N4 = $i or N5 = $i)
LIMIT 50
How to count only 50 results??
I've tryied this with no sucess
$sql= "SELECT * FROM euro where (N1 = $i or N2 = $i or N3 = $i or N4 = $i or N5 = $i) LIMIT 50";
$query = "select COUNT(Id) As Total FROM ($sql) as a"
or this:
$sql= "SELECT * FROM euro LIMIT 50";
$query = "select COUNT(Id) As Total FROM ($sql) as a where (N1 = $i or N2 = $i or N3 = $i or N4 = $i or N5 = $i)"
I'm not quite sure if I understand last part on results give all 50
I have this table:
Id date dayofweek N1 N2 N3 N4 N5 E1 E2
1 2004-02-13 Friday 1 4 12 41 50 1 4
2 2004-02-28 Friday 2 5 32 33 39 4 6
3 2004-03-10 Tuesday 23 26 43 44 49 9 10
I had this:
$query = "select COUNT(Id) AS Total from euro
where (N1 = $i or N2 = $i or N3 = $i or N4 = $i or N5 = $i)";
And it worked counting in an efficient way for all the records in table so it means it must respect that part.
Now I have :
$query = "select COUNT(N1) As Total FROM (SELECT * FROM euro
where $i in (N1, N2, N3, N4, N5) Order By Id Desc LIMIT 50) a";
And it gives 50 to all counting... I can't understand...