Forum Moderators: open

Message Too Old, No Replies

INSERT . SELECT query not working

         

mrscruff

12:48 pm on Sep 18, 2009 (gmt 0)

10+ Year Member



Hello

I'm trying to run this insert select query, but just give the following error:

Line 1: Operand should contain 1 column(s)

Line1: INSERT INTO catorgories_links (doc_id, cat_id, visible, add_datetime)
Line2: SELECT (ID+'136', '1', '1', NOW()) FROM foi WHERE ps1 ='x'

I need to add 136 to the id value, which will match the id in the table that the cat link table will be with.

The select query will run, and return correct result when run by it's self, but not in this format.

Thanks

mark_roach

1:30 pm on Sep 18, 2009 (gmt 0)

10+ Year Member



Do you get the same error if you remove the quotes around 136 ?

mrscruff

1:41 pm on Sep 18, 2009 (gmt 0)

10+ Year Member



Yes

Also fyi: MySQL 4.1.18

And before you ask there is NOTHING I can do about it! :(

mrscruff

9:58 am on Sep 21, 2009 (gmt 0)

10+ Year Member



Got it working, used:

INSERT INTO catorgories_links (doc_id, cat_id, visible, add_datetime)
SELECT (ID+136), '1', '1', NOW() FROM foi WHERE ps1 ='x'