Forum Moderators: coopster

Message Too Old, No Replies

simple sql question

         

webnoob

3:06 am on Jun 5, 2005 (gmt 0)

10+ Year Member



say i have two fields:

table1.title ¦ table2.topic

how do i create an IF statement to select table2.topic if table1.topic is empty, ie NULL?

i thought this might work but i think i am wrong..

IF(table1.title IS NOT NULL, table1.title, table2.topic) AS topic

coopster

8:52 pm on Jun 5, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you running that statement on a MySQL database? Did you test it? It looks correct to me, providing you are using MySQL as the database or another database with a similar IF() function.

Are you sure the value in your test statement is NULL and not just empty? You may want to check that as well.