Hi everyone 🙂
I have a query that selects fields from two joined tables.
Everything works fine unless I got a field of the joined table in the WHERE (or/and ORDER BY) clause :\
Then I receive the following error-message: "Unknown table 'curl_isles' in where clause"
First it's weird that the MySQL server doesn't complain about the fields of the joined table in the SELECT statement. Furthermore SHOW TABLES returned all tables. So the script can find curl_isles. And finally the queries work fine if pasted into phpMyAdmin which is the most confusing part of all :queasy:
Here's a query that works in the script:
SELECT
`isles`.`pos`,`collected`,
`curl_isles`.`owner`, `curl_isles`.`team`,
`u1`, `u2`, `u3`, `u4`,
`s1`, `s2`, `s3`, `s4`, `s5`,
`t1`, `t2`, `t3`, `t4`, `t5`,
`b1`, `b2`, `b3`, `b4`, `b5`, `b6`, `b7`, `b8`, `b9`, `b10`, `b11`,
`r1`, `r2`, `r3`
FROM `isles` JOIN `curl_isles` USING (`pos`)
WHERE `isles`.`pos` LIKE '%:%:%' AND `isles`.`collected` >= '1117207965'
ORDER BY `collected` DESC LIMIT 0,20
And this is a query that works in phpMyAdmin but not in the script:
SELECT
`isles`.`pos`,`collected`,
`curl_isles`.`owner`, `curl_isles`.`team`,
`u1`, `u2`, `u3`, `u4`,
`s1`, `s2`, `s3`, `s4`, `s5`,
`t1`, `t2`, `t3`, `t4`, `t5`,
`b1`, `b2`, `b3`, `b4`, `b5`, `b6`, `b7`, `b8`, `b9`, `b10`, `b11`,
`r1`, `r2`, `r3`
FROM `isles` JOIN `curl_isles` USING (`pos`)
WHERE `isles`.`pos` LIKE '%:%:%' AND `curl_isles`.`owner` LIKE 'Devil' AND `isles`.`collected` >= '1117208102'
ORDER BY `collected` DESC LIMIT 0,20
As the error comes from the Database and I print the queries I use in phpMyAdmin just before I send them to the MySQL server I assume that it must be a MySQL related problem. But anyway, here's the related part of my PHP script:
include("mysql.php");
$SQL_query = " SELECT
`isles`.`pos`,`collected`,
`curl_isles`.`owner`, `curl_isles`.`team`,
`u1`, `u2`, `u3`, `u4`,
`s1`, `s2`, `s3`, `s4`, `s5`,
`t1`, `t2`, `t3`, `t4`, `t5`,
`b1`, `b2`, `b3`, `b4`, `b5`, `b6`, `b7`, `b8`, `b9`, `b10`, `b11`,
`r1`, `r2`, `r3`
FROM `isles` JOIN `curl_isles` USING (`pos`) ".$SQL['where']."
ORDER BY `".$SEARCH['sort_by']."` ".$SEARCH['sort_style'].$SQL['limit'];
print "<pre>".$SQL_query."</pre>";
$QRY = mysql_query($SQL_query) or die(mysql_error());
mysql_close();
Does anyone has an idea what could be wrong or what I could try to fix this problem?
I'm at the end of my wisdom :xbones: