mySQL query: How to insert with UNION?

Posted by Industrial on Stack Overflow See other posts from Stack Overflow or by Industrial
Published on 2010-06-02T13:41:50Z Indexed on 2010/06/02 13:43 UTC
Read the original article Hit count: 207

Filed under:
|
|
|

Hi everybody,

I am kind of new to mySQL:s union functions, at least when doing inserts with them. I have gotten the following to work based upon a example found on the net:

INSERT INTO tableOne(a, b)
SELECT a, $var FROM tableOne
WHERE b = $var2
UNION ALL SELECT $var,$var

Ok, nothing strange about that. But what happens when I want to insert a third value into the database that has nothing to do with the logic of the Select being done?

Like : INSERT INTO tableOne(a, b, c )

How could that be done?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about select