Jump to content

SQL question. Is it possible to....


sbayeta

Recommended Posts

Hi,

I have a table with the fields \"id\", \"value\", \"value_on_nick\" and \"value_of_nick\", and some rows that look like:


|   id  | value | value_on_nick | value_off_nick |

|-------|-------|---------------|----------------|

| item1 |   0   |    abnormal   |      normal    |

| item2 |   1   |      cold     |       hot      |

 

Is it possible to create a query that will return the item id and the nick corresponding to the value ? Like

 


|   id  |  nick  |

|-------|--------|

| item1 | normal |

| item2 |  cold  |

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/541-sql-question-is-it-possible-to/
Share on other sites

Yes... use a select in combination with IF....

 

check the syntax of the IF, then write if you need more help...

 

 

I.e. select ID, if (value =1, NICK_ON, nick_off) FROM TABLE....

 

The above is probably not the correct syntax, but you get the idea.

 

P.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.