Page 1 of 1

MySQL: SELECT 0 FROM....

Posted: Sun Sep 18, 2005 8:08 pm
by Skara
I think in Oracle you can do a 'select 0' thing. I'm not familiar with the language, so I'm not sure.

Anyway, I just want to check if something is in a database. Erhm.. basically...

Code: Select all

| 2 | 3 |
| 3 | 3 |
| 5 | 1 |
| 3 | 7 |

Code: Select all

SELECT ??? FROM table WHERE row1='5' AND row2='1';
...if (mysql_num_rows()), do whatever
Should I put something different where the ??? are, or should I just put 'row1' there?

Posted: Sun Sep 18, 2005 8:10 pm
by timvw

Code: Select all

SELECT COUNT(*) AS count FROM table WHERE ....
Now, count will tell you how many entities there are that meet your criteria..

Posted: Sun Sep 18, 2005 9:21 pm
by John Cartwright
if your using COUNT then you actually have to fetch `count`, rather than mysql_num_rows().