Re: SELECT COUNT - result from two tables

From: Date: Thu, 06 Nov 2003 04:25:50 +0000
Subject: Re: SELECT COUNT - result from two tables
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-31466@lists.php.net to get a copy of this message
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).


« previous php.db (#31466) next »