windandwaves wrote:
Hi Folk
How do I use the if then else statement in an SQL statement.
I tried this:
SELECT (IF SSG.ID = SSI.ID then true else false) a, SSG.ID gid, SSG.NAM
gnam, SSI.ID iid, SSI.NAM inam, SSI.NAM inam
FROM SSG, SSI
WHERE SSI.SSG_ID = SSG.ID AND SSI.STA =1 AND ( SSG.ID = SSI.ID OR SSI.SSG_ID
= '10' )
ORDER BY SSG.SOR, SSI.SOR;
What am I doing wrong?
- Nicolaas
From recollection I think it should be something like this:
SELECT IF(SSG.ID = SSI.ID, true, false), a, SSG.ID gid, SSG.NAM gnam,
SSI.ID iid, SSI.NAM inam, SSI.NAM inam
(See also:
http://dev.mysql.com/doc/mysql/en/co...functions.html)
It looks like you are using spaces in your field names, I don;t think
this is a very good idea. If you would like to keep names readable the
spaces are most of the times replaced by underscores (_).
Good luck!
Jonathan
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?