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
2009-11-21 16:24:41
NO, this is a SELECT command in an INSERT command. I need a INSERT/UPDATE/equivalent inside an SELECT command.
Amanda Smith
2009-11-21 16:53:58
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
2009-11-21 17:13:17