|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Defining a new column in a SELECT
Hi,
I'm looking for a way to define ("create") a new column, in an SQL SELECT query, which retrieves 2 variables (a and b) and creates a third one (c). In the example below, variable c is supposed to be boolean: if a = b then c will hold 1, otherwize c will hold 0. SELECT a, b, c How can i do it in a SELECT statement ? Thanks, Yigal |
|
#2
|
||||
|
||||
|
you were actually pretty close
select a , b , case when a=b then 1 else 0 end as c from yourtable rudy http://r937.com/ |
|
#3
|
|||
|
|||
|
Hi rudy,
Thank you very much for your help. As a matter of fact, I'm embeding SQL in a Delphi program (did u here about it ? - Borland's), using a very old but still good database called Paradox. I tried the case syntax u offered but Paradox's SQL didn't recognize this keyword - I believe it's because Paradox's SQL is very old and not up to date. I'm sure it will work on MySQL, which I'm going to migrate my database to. Maybe you know where I can find a complete guide to SQL on the net, and I mean somethig that will also say which commands are extensions of MySQL etc. Again, Thank you. Yigal |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Defining a new column in a SELECT |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|