Need to select values as aliases?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Need to select values as aliases?

Post by Luke »

I have this query:

Code: Select all

SELECT 
    s01_CFM_ProdValues.value,
    s01_CFM_ProdFields.code
FROM 
    s01_CFM_ProdFields,
    s01_CFM_ProdValues,
    s01_Products
WHERE
    s01_CFM_ProdValues.product_id = s01_Products.id
AND
    s01_CFM_ProdValues.field_id = s01_CFM_ProdFields.id
AND
    s01_Products.code = 'ELL001A'
AND
    s01_CFM_ProdFields.code IN ('color','mfcd')
It returns exactly the information I need, but not really how I need it. It returns this:

Code: Select all

value   code (column names)
Blue    COLOR
ELL     MFCD
And I need it to return this:

Code: Select all

COLOR   MFCD (column names)
Blue    ELL
Any idea how I can do that?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'm pretty sure you'll have to do the rotation yourself.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

that's what I figured... but I had to check. I am no sql guru. thanks feyd. :)

unfortunately I have to do it in mivascript... grumble grumble... :evil:

I HATE MIVASCRIPT
Post Reply