Jump to content

[SOLVED] inserting based on results of a subquery select


Recommended Posts

Hello there,

 

I have the following code:

 

INSERT INTO block (fin, who_blocked) VALUES (irs_rawdata.EIN, 'S-123456789')
WHERE NOT EXISTS
(
SELECT * FROM irs_rawdata
  PNO LIKE '%blind%' OR
  PNO LIKE '%deaf%' OR
  NTEE_Code LIKE '%P87%'
);

 

I have done it with using * in the select and also with EIN as this is the only field need to be inserted into the block table,

 

what am I doing wrong as its saying that there is a error near the WHERE NOT EXISTS clause?

 

Thanks for any help!

 

Sincerely,

Christopher

You can't have a "where" condition after "values" like that in the "insert". You can specify a "select" to retrieve values from another table to be used to "insert" (and for that you place the "select" right after "values").

 

Look at the Insert syntax in the manual:

http://dev.mysql.com/doc/refman/5.0/en/insert.html

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.