Forum Moderators: coopster
It's a little trickier than usual but I'll try to explain it and show what I have come up with already.
Table A fields : ID and Variable
Table B fields : ID and Status
What I would like is a query which shows a count of the number of results we get from Variable being X from table A and where the Status is not StatusA or StatusB.
So far the query which I've come up with is
$Result = mysql_query(
"SELECT COUNT(*) AS count
FROM TableA
INNER JOIN TableB ON TableA.ID = TableB.ID
WHERE TableA.Variable = '$X'
AND TableB.Status!== 'StatusA' ¦¦ TableB.Status!== 'StatusB'"
); How am I doing with this query?
WHERE TableA.Variable = '$X'
AND TableB.Status!== 'StatusA' ¦¦ TableB.Status!== 'StatusB'"
I think you want an AND instead of an OR as the final condition in your WHERE clause ...
AND TableB.Status!= 'StatusA' AND TableB.Status!= 'StatusB' ...
Shorter way to write it:
AND TableB.Status NOT IN ('StatusA', 'StatusB') ...