SELECT Doesn't work

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
gastonlm
Forum Commoner
Posts: 26
Joined: Tue May 07, 2002 10:19 am
Location: Buenos Aires, Argentina
Contact:

SELECT Doesn't work

Post 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?
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post 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.
gastonlm
Forum Commoner
Posts: 26
Joined: Tue May 07, 2002 10:19 am
Location: Buenos Aires, Argentina
Contact:

Post by gastonlm »

I was doing something wrong. Now I could do.
Thanks.
User avatar
sam
Forum Contributor
Posts: 217
Joined: Thu Apr 18, 2002 11:11 pm
Location: Northern California
Contact:

Post 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
Post Reply