Re: [PHP-DB] SELECT COUNT - result from two tables

2003-11-06 Thread CPT John W. Holmes
From: Boyan Nedkov [EMAIL PROTECTED] Putting more than one table in the FROM clause means tables are joined, then at least following problems could arise: - using WHERE clause you can have empty recordset returned and then COUNT conflicts with it because there is actually no any data to be

[PHP-DB] SELECT COUNT - result from two tables

2003-11-05 Thread Mark Gordon
I cannot seem to get a SELECT COUNT for a query from fields in two different tables and a WHERE clause. Does anyone know if this is not possible with php/mysql or am I doing something wrong? I have tried a number of variations on the following code: $sql = SELECT COUNT(*), bandid, bandname,

Re: [PHP-DB] SELECT COUNT - result from two tables

2003-11-05 Thread John W. Holmes
Mark Gordon wrote: I cannot seem to get a SELECT COUNT for a query from fields in two different tables and a WHERE clause. Does anyone know if this is not possible with php/mysql or am I doing something wrong? I have tried a number of variations on the following code: $sql = SELECT COUNT(*),

Re: [PHP-DB] SELECT COUNT - result from two tables

2003-11-05 Thread Mark Gordon
Yes, query is definitely working without COUNT(*). Even in the most stripped down form, the query fails: $sql = SELECT COUNT(bandid), genre FROM bands, genre; $result=mysql_query($sql); while ($gen=mysql_fetch_row($result)) { echo $gen[1]; } John W. Holmes [EMAIL PROTECTED] wrote: Mark Gordon

Re: [PHP-DB] SELECT COUNT - result from two tables

2003-11-05 Thread John W. Holmes
Mark Gordon wrote: Yes, query is definitely working without COUNT(*). Even in the most stripped down form, the query fails: $sql = SELECT COUNT(bandid), genre FROM bands, genre; $result=mysql_query($sql); while ($gen=mysql_fetch_row($result)) { echo $gen[1]; } Fails how? If it echos zero, it's

Re: [PHP-DB] SELECT COUNT - result from two tables

2003-11-05 Thread Boyan Nedkov
Putting more than one table in the FROM clause means tables are joined, then at least following problems could arise: - using WHERE clause you can have empty recordset returned and then COUNT conflicts with it because there is actually no any data to be returned; - joining two (or more)