Do you have a question? Post it now! No Registration Necessary. Now with pictures!
April 18, 2005, 9:23 pm
rate this thread
I would like to execute the following query to perform deletes.
Unfortunately it only returns a list of the delete queries without
actually performing them. How can I get the deletes to be executed? I
am running MySQL 4.0.20-standard.
$query = "SELECT concat('DELETE FROM temp WHERE prodid =
'',prod.ProdID, '';') AS '' FROM prod LEFT JOIN catalog ON
prod.ProdID = catalog.ProdID WHERE catalog.ProdID IS NULL";
All help really appreciated!
Re: DELETE within SELECT
Well, you can execute this query and get results back, right? So each
row of the result set becomes a new $query that you can execute.
Another option is to use a multi-table delete, which is a clever (but
non-standard) extension to SQL implemented in MySQL. For example:
DELETE FROM temp
USING temp INNER JOIN prod ON temp.prodid = prod.ProdID
LEFT OUTER JOIN catalog ON prod.ProdID = catalog.ProdID
WHERE catalog.ProdID IS NULL
See http://dev.mysql.com/doc/mysql/en/delete.html for more info on the
- » Getting rid of the failed setups in MyODBC driver?
- — Next thread in » MySQL Database Forum
- » Question on a query to find all possible combinations of a set
- — Previous thread in » MySQL Database Forum
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum