Re: Join causing Error?
| From: | Bob Hall | Date: | Sun, 25 Feb 2001 15:56:51 +0000 |
| Subject: | Re: Join causing Error? | ||
| References: | 1 | Groups: | php.db php.general |
| Request: | Send a blank email to php-general+get-41591@lists.php.net to get a copy of this message | ||
Sir, I don't see anything wrong with the syntax in your query. If I haven't over looked something, and if you haven't misspelled anything, then you have a data problem. Since your first query returns a Cartesian product, you should get something if the WHERE clause returns >= 1 row for each table. So either there are no rows in q that meet the conditions
q.active = '1' AND q.global = '1'
or there are no rows in c that meet the condition
c.active = '1'
Run the first query with only the first WHERE condition. If you get rows, add the second condition. If that works, add the third. The point at which the query stops returning rows is the point at which a subset of your WHERE conditions aren't met by the any of the rows in one of the tables.
BTW, why are you putting quotes around numbers? I'm assuming that's not the problem, since you say you did it in the query that worked, but I don't see the point.
Bob Hall
Can anyone tell me why this:Know thyself? Absurd direction!Line 282 mysql_select_db("centraldb",$db); Line 283 $qorder++; Line 284 $result = mysql_query("SELECT q.questid, q.question, q.answer, q.qorder, q.depart, q.catid, q.active, q.global, q.adate, q.author, q.authoremail, q.askemail, c.catid, c.category, c.under, c.corder, c.active FROM central_groupfaqq q, central_groupfaqcat c WHERE q.active = '1' AND q.global = '1' AND c.active = '1' ORDER BY c.under, c.order, q.qorder",$db); Line 285 while ($myrow = mysql_fetch_row($result))Would cause this error: Warning: Supplied argument is not a valid MySQL result resource in faqbody.php3 on line 285 When changing the same SELECT statement to:Line 284 $result = mysql_query("SELECT * FROM central_groupfaqq WHERE active = '1' ORDER BY qorder",$db);Works perfectly? Keith Spiller a.k.a. Larentium
Bubbles bear no introspection. -Khushhal Khan Khatak