SELECT COUNT - result from two tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, genre
FROM bands, genre
WHERE genre.genreid=$g
AND bands.genreid=genre.genreid
ORDER BY bandname ASC";
$gen = mysql_fetch_row(mysql_query($sql)); 
echo $gen[0];
 
I know from documentation that COUNT works with WHERE clauses...but also from two tables?
 
Thanks everyone


---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux