tags:

views:

57

answers:

1

Is there any way to run UPDATE or INSERT inside a SELECT statement in mysql?

+1  A: 

Something like this?

INSERT california_authors (au_id, au_lname, au_fname)
SELECT au_id, au_lname, au_fname
FROM authors
WHERE State = 'CA'

More on that matter: http://www.sqlteam.com/article/using-select-to-insert-records

The MYYN
NO, this is a SELECT command in an INSERT command. I need a INSERT/UPDATE/equivalent inside an SELECT command.
Amanda Smith
You select something and then you try to insert/update something, based on the select, because otherwise you could just select or just insert/update. Maybe i'm wrong, but from the 'task' perspective the above might fulfill what you try to do (even though not formally ..).
The MYYN