Re: SELECT COUNT - result from two tables

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

 




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) tables without using aliases to the equally named columns in the SELECT/WHERE/COUNT clauses will produce error message instead of expecting data;

- COUNT(*) wont work if u have equal table names in the tables;

If you give us some more detail description of the tables then it will be easier to find where the problem is


Boyan --



John W. Holmes wrote:

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 not failing; your query just isn't returning any rows (regardless whether you think it should or not).


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


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

  Powered by Linux