Unix Technical Forum

Select .. WHERE lang="nl" or lang="en"

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 10:09 AM
dag
 
Posts: n/a
Default Select .. WHERE lang="nl" or lang="en"

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?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 10:09 AM
Paul Lautman
 
Posts: n/a
Default Re: Select .. WHERE lang="nl" or lang="en"

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!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 10:09 AM
dag
 
Posts: n/a
Default Re: Select .. WHERE lang="nl" or lang="en"

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 10:09 AM
Captain Paralytic
 
Posts: n/a
Default Re: Select .. WHERE lang="nl" or lang="en"

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 10:11 AM
dag
 
Posts: n/a
Default Re: Select .. WHERE lang="nl" or lang="en"

> 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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com