MySQL Forums
Forum List  »  General

Re: Insert into with IF condition
Posted by: Rui Cunha
Date: September 03, 2011 07:07AM

Rick,


Thanks very much for your help.
This query that you used worked like a charm:

>> INSERT INTO tbl (col) VALUES ( IF(condition, 'this', 'that') );


For future references a friend of mine told me to try this query, and worked too:

>> INSERT INTO tbl(col) SELECT 'this' AS col from dual where 1=1;

he explain that dual is like a virtual or temporary table.


Regard,

Rui Cunha

Options: ReplyQuote


Subject
Written By
Posted
August 26, 2011 09:33AM
Re: Insert into with IF condition
September 03, 2011 07:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.