Professional Web Applications Themes

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

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

  1. #1

    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?

    dag Guest

  2. #2

    Default Re: Select .. WHERE lang="nl" or lang="en"

    dag wrote: 

    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!


    Paul Guest

  3. #3

    Default Re: Select .. WHERE lang="nl" or lang="en"

    On 2 Lip, 16:05, "Paul Lautman" <com> wrote: 


    >
    > 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![/ref]

    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.

    dag Guest

  4. #4

    Default Re: Select .. WHERE lang="nl" or lang="en"

    On 3 Jul, 21:19, dag <com> wrote: [/ref]
    > [/ref]
    > [/ref]


    >
    > 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 -[/ref]

    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.

    Captain Guest

  5. #5

    Default Re: Select .. WHERE lang="nl" or lang="en"

    > Just to get this straight. 

    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.

    dag Guest

Similar Threads

  1. Replies: 0
    Last Post: August 26th, 06:01 AM
  2. Replies: 1
    Last Post: April 24th, 01:27 PM
  3. CFINPUT type="radio" w/ "value" requires "label"
    By Iceborer in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 21st, 06:16 PM
  4. "Start" "Program" "Menu" list is empty
    By Pete in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 10th, 10:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139