Click to See Complete Forum and Search --> : sql where statement
d3lia5
04-17-2006, 04:58 AM
hello..
please help me on this..
$sel = "select B.club, count(B.club) from student A, school B
WHERE A.loginID = B.loginID AND A.class = '4' AND A.class = '5'
GROUP BY B.club";
thank you..
chazzy
04-17-2006, 07:11 AM
Without knowing what you are looking for exactly, what is happening with this query, and what your tables look like, we really can't do anything over here.
aaronbdavis
04-17-2006, 06:57 PM
Lets take a look at this:
select B.club, count(B.club) from student A, school B
WHERE A.loginID = B.loginID AND A.class = '4' AND A.class = '5'
GROUP BY B.club"
This statement will never return any rows: A.class = '4' and A.class = '5' is contradictory. A.class can only hold 1 value and it will never be both 4 and 5 at the same time. I am guessing that you want those rows where the value of A.class is either 4 or 5 you would do this using ...AND (A.class=4 OR A.class=5)
Also, I am guessing that the datatype for A.class is an integer. If this is the case, then you do not need to place 4 and 5 in quotes.
If you need more help, please give us a more specific question and we will try to help you.
audux
04-20-2006, 11:39 PM
i think you forgot to put a column name after your count function
try this count(B.club) as clubcnt,
i experienced one when using vb6, program returns an error since i haven't provide a column name when an object retrieves a value from a recordset.