Sebastian wrote:

I have two fields: topic | title

topic does not always have data in it, so i want to select `title` when `topic` is null..

i thought i could do this (does not work):

IF(title IS NULL, topic, title) AS heading

Thanks.

There is nothing wrong with this, as long as it is part of a complete query.

  SELECT IF(title IS NULL, topic, title) AS heading FROM yourtable;

should do exactly what you say you want.  Simon Garner's suggestion

  SELECT IFNULL(title, topic) AS heading FROM yourtable;

should work, as well.

General advice: "does not work" is nearly useless when asking questions. You need to describe the problem to get useful help. Show the complete query, then tell us what went wrong. Did you get an error message? If so, paste it in. Did you get unexpected results? If so, show us what you got and what you expected. Also, be sure to include the version of mysql you use, as answers often depend on the version.

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to