Hi, I have those tables:

CREATE TABLE citys (
   id mediumint(8) unsigned NOT NULL auto_increment,
   name varchar(100) NOT NULL,
   UNIQUE id (id)
);

CREATE TABLE route (
   id mediumint(8) unsigned NOT NULL auto_increment,
   id_from mediumint(8) unsigned DEFAULT '0' NOT NULL,
   id_to mediumint(8) unsigned DEFAULT '0' NOT NULL,
   UNIQUE id (id)
);

id_from and id_to are id's relationed with citys.id

Now I want to get it with the names:

SELECT citys.name as city_from, citys.name as city_to FROM citys,route
WHERE route.id_from=citys.id AND route.id_to=citys.id;

Obviusly that is wrong... so... how can I get both city names?

Thanks!

database,sql,query



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to