PDA

View Full Version : Weird mySQL query problem



ashben
December 3rd, 2000, 02:25
I have this SQL query :

select A.Name, B.Age from A inner join B on A.ID=B.ID

.. on two MySQL DB tables namely A and B. But it results in a "Warning: Supplied argument is not a valid MySQL result resource in ... " message under PHP. I'm running mySQL 3.23 and yes, both the join condition parameters (A.ID & B.ID) are of the same data type (i.e. MediumInt(11)-Unsigned).

What's wrong with the above SQL query syntax or the join itself.

Any help is appreciated!

atlas
December 3rd, 2000, 10:32
select A.Name, B.Age from A,B where A.ID=B.ID


mjk@atlascgi.com

ashben
December 3rd, 2000, 11:49
Thanks atlas. Giving away the JOIN and using the WHERE condition helped. But could you (or anyone) please tell me why doesnt the JOIN thing work & secondly is the WHERE condition as efficient as a JOIN in this case.

Any help is appreciated!

atlas
December 4th, 2000, 10:32
What version of mySQL do you have running? Versions previous to 3.23.16 didn't allow INNER JOIN to take any conditions like 'on.'

Otherwise your syntax is correct. I just use the where clause since it's easier for basic table joins -- I have no idea about the efficiency.

Hope this helps

mjk@atlascgi.com

ashben
December 4th, 2000, 11:06
I guess that explains it since I'm running MySQL 3.22

Thanks!