RE: [PHP-DB] Re: difficult sql statement. Help needed

From: Date: Wed, 10 Apr 2002 14:53:24 +0000
Subject: RE: [PHP-DB] Re: difficult sql statement. Help needed
Groups: php.db 
Request: Send a blank email to php-db+get-18393@lists.php.net to get a copy of this message
You need to look up LEFT JOIN in the documention of the database you are using. > > "Andy" <news.letters@gmx.de> wrote in message > news:20020410132621.79283.qmail@pb1.pair.com... > > Hi there, > > > > I do have a sql statement where I could need some help on. > > > > There are 3 tables: provinces, cities, countries > > The result should be city, province, country but only if province is > > available. If not just display city and country.! > > > > Lets say we are searching for madrid. > > > > I did build following statement: > > SELECT c.city, c.ID, p.province, co.country FROM > cities c, provinces > p, > > countries co WHERE c.city like 'madrid%' AND p.province_id > = c.province_id > > AND p.country_code = c.country_code AND c.country_code = > co.country_code > > ORDER BY country , province limit 0, 10 > > > > > > Works fine as long as there is a province for this city. But > unfortunatelly > > my db does not have for all countries provinces. But there > is a madrid in > > spain. > > so I would like to change this querry to return madrid in > spain even if > the > > province is unknown, but also if the province exists (in > this case with > the > > name of the province) > > > > Maybe there is a way to do if statements in sql?? > > > > Thanx for any help > > > > Andy > > > > > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.db (#18393) next »