[SQL] return two rows from one

Discussion in 'Web Design & Coding' started by Geffy, Jun 9, 2006.

  1. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    I have a slight problem. I am wanting to optimise a set of tables which seem to have been modelled on text based config files (not the wisest idea) for a server application I have to manage.

    The table format I want to use is distributed over a couple of different tables which I can link together without much trouble.

    The trouble is that the server application wants the data back like this for a specific username:
    id, username, attribute, value, op
    10, chickens@tempuri.org, Framed-IP-Address, 192.168.1.138, :=
    11, chickens@tempuri.org, cisco-avpair, ip:route=192.168.1.1, :=

    The lookup is based on the username for the existing database format.

    So how can I somehow maybe join up two queries to return two distinct rows of data?

    edit: this has to work with MySQL 4.1 btw ;)
     
    Last edited: Jun 9, 2006
  2. Khayman

    Khayman I'm sorry Hal... Political User Folding Team

    Messages:
    5,518
    Location:
    England
    a simple UNION won't work?
     
  3. Electronic Punk

    Electronic Punk Administrator Staff Member Political User Folding Team

    Messages:
    18,590
    Location:
    Copenhagen, Denmark
    if you said WHERE username = wuldn't that return two rows?
     
  4. LordOfLA

    LordOfLA Godlike!

    Messages:
    7,027
    Location:
    Maidenhead, Berkshire, UK
    you can't return two rows of data with one query unless the data is on two rows in the database as far as I'm aware.
     
  5. Geffy

    Geffy Moderator Folding Team

    Messages:
    7,805
    Location:
    United Kingdom
    bugger then, this is what I am needing to do. Will have to investigate if I can stick something in between the database and the application to fetch the data and convert it into what it needs.

    @Khayman: I think I need an anti-Union, one query split into two result rows