SQL questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    SQL questions

    I have table "lists" with columns "id" (key) and "container" which implement
    a connected list like that:
    id | container
    1 | NULL
    2 | 1
    3 | NULL
    4 | 1
    5 | 6
    6 | 4
    7 | 4
    8 | 7

    is there a query to get the whole list in one row until it find NULL like
    that???
    1 NULL
    2 1 NULL
    3 NULL
    4 1 NULL
    5 6 4 1 NULL
    6 4 1 NULL
    7 4 1 NULL
    8 7 4 1 NULL

    ----------------------------------------------------------------------------
    -----

    We suppose now that we JOIN upper table "lists" with table "strings" ON
    lists.id = strings.id
    Table "strings" has columns "id" (key), "language" (key) and "string" like
    this:
    id | language | string
    1 | english | OpenGL
    1 | german | [NULL]
    2 | english | Java
    2 | german | [NULL]
    3 | english | News
    3 | german | Nachrichten

    I want a query which when german "language" has "string" NULL return english
    "language"
    I construct something like this but it is incomplete:

    SELECT lists.id, container, IFNULL(a.string , 'What I must give here?????')
    FROM lists JOIN strings ON lists.id=string s.id WHERE language=<somet hing>


Working...