Page 1 of 1

SELECT Doesn't work

Posted: Wed May 22, 2002 1:42 pm
by gastonlm
I'm running the following selection and I don't recive any results. I should have results, but I'm new to MySql and I don't know if I'm doing something unsupported by MySql.
I'm trying to bring the name of a city from a table with the city code taht is a foreing key in another table.
The selection is:
SELECT h.name,c.name FROM hotel h, city c WHERE h.cityID = 15 and c.id = h.cityID
I made other selections and it works badly. Am I doing something wrong?

Posted: Wed May 22, 2002 2:54 pm
by MattF
That looks like some very complicated SQL for a beginner it doesn't look much like mySQL to me. I suggest doing several queries to get your results.

Posted: Wed May 22, 2002 3:01 pm
by gastonlm
I was doing something wrong. Now I could do.
Thanks.

Posted: Wed May 22, 2002 6:18 pm
by sam
MattF wrote:That looks like some very complicated SQL for a beginner it doesn't look much like mySQL to me. I suggest doing several queries to get your results.
No it is more robut to do joins like the one he proposed than to do multipal queries.

Cheers Sam