This is a discussion on Select .. WHERE lang="nl" or lang="en" within the MySQL forums, part of the Database Server Software category; --> Hi, I have a table `cities`: city_id countrycode languagecode name primary key (city_id, languagecode) I want fetch all cities ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I have a table `cities`: city_id countrycode languagecode name primary key (city_id, languagecode) I want fetch all cities with countrycode="fr" and languagecode="nl", If city_id in languagecode="nl" not exists, I want fetch THIS city in languagecode="en" EXAMPLE: city_id countrycode languagecode name: 1 fr en Paris 2 fr en Bordeaux 1 fr pl Paryż 2 fr pl (null OR '') countrycode="fr" and languagecode="pl": 2 fr en Bordeaux 1 fr pl Paryż Any ideas? |
| |||
| dag wrote: > Hi, > > I have a table `cities`: > city_id > countrycode > languagecode > name > primary key (city_id, languagecode) > > I want fetch all cities with countrycode="fr" and languagecode="nl", > If city_id in languagecode="nl" not exists, I want fetch THIS city in > languagecode="en" > > > EXAMPLE: > city_id countrycode languagecode name: > 1 fr en Paris > 2 fr en Bordeaux > 1 fr pl Paryż > 2 fr pl (null OR '') > > countrycode="fr" and languagecode="pl": > 2 fr en Bordeaux > 1 fr pl Paryż > > > Any ideas? You said: 'If city_id in languagecode=... not exists, I want fetch THIS city in languagecode="en"' But in the example you have given, the city_id 2 with countrycode = "fr" and languagecode="pl" DOES exist, and yest you have said that the output should ignore it! |
| |||
| On 2 Lip, 16:05, "Paul Lautman" <paul.laut...@btinternet.com> wrote: > > EXAMPLE: > > city_id countrycode languagecode name: > > 1 fr en Paris > > 2 fr en Bordeaux > > 1 fr pl Paryż > > 2 fr pl (null OR '') > > > countrycode="fr" and languagecode="pl": > > 2 fr en Bordeaux > > 1 fr pl Paryż > > > Any ideas? > > You said: 'If city_id in languagecode=... not exists, I want fetch THIScity > in > languagecode="en"' > > But in the example you have given, the city_id 2 with countrycode = "fr" and > languagecode="pl" DOES exist, and yest you have said that the output should > ignore it! Yes, I want ignore rows with empty Name. In other way, I can delete all rows which have name=="", after I added data to table. 1. the city_id 2 with countrycode = "fr" and languagecode="pl" DOES exist with empty name (name="") 2. the city_id 2 with countrycode = "fr" and languagecode="pl" DOESN'T exist I'm looking for tips. |
| |||
| On 3 Jul, 21:19, dag <dagers...@gmail.com> wrote: > On 2 Lip, 16:05, "Paul Lautman" <paul.laut...@btinternet.com> wrote: > > > > > > > > EXAMPLE: > > > city_id countrycode languagecode name: > > > 1 fr en Paris > > > 2 fr en Bordeaux > > > 1 fr pl Paryż > > > 2 fr pl (null OR '') > > > > countrycode="fr" and languagecode="pl": > > > 2 fr en Bordeaux > > > 1 fr pl Paryż > > > > Any ideas? > > > You said: 'If city_id in languagecode=... not exists, I want fetch THIS city > > in > > languagecode="en"' > > > But in the example you have given, the city_id 2 with countrycode = "fr" and > > languagecode="pl" DOES exist, and yest you have said that the output should > > ignore it! > > Yes, I want ignore rows with empty Name. > > In other way, I can delete all rows which have name=="", after I added > data to table. > > 1. > the city_id 2 with countrycode = "fr" and > languagecode="pl" DOES exist with empty name (name="") > > 2. > the city_id 2 with countrycode = "fr" and > languagecode="pl" DOESN'T exist > > I'm looking for tips.- Hide quoted text - > > - Show quoted text - Just to get this straight. In your first post you said: 'If city_id in languagecode="nl" not exists, I want fetch THIS city in languagecode="en"' But you are now saying this is wromg. Instead you want 'If name is blank, I want to fetch this city in languagecode="en"' Or do you still want the first. It makes a difference as to what the answer will be. |
| ||||
| > Just to get this straight. > > In your first post you said: > 'If city_id in languagecode="nl" not exists, I want fetch THIS city in > languagecode="en"' > > But you are now saying this is wromg. > > Instead you want > 'If name is blank, I want to fetch this city in languagecode="en"' > > Or do you still want the first. It makes a difference as to what the > answer will be. Hi CASE #1 the city_id 2 with countrycode = "fr" and languagecode="pl" *DOES exist* with empty name (name="") if not solved case #1 (because I can delete all rows with name=""): CASE #2. the city_id 2 with countrycode = "fr" and languagecode="pl" *DOESN'T exist* So, I'm looking for tips for CASE #1, if this isn't to solve, for Case #2. |