I have the following MySQL query which performs a simple update. There's a sub query after the and clause which works as a separate query, the main query also works on it's own i.e without the sub query (with some valid numeric value in place). I get the following error however:
Error Code: 1093. You can't specify target table 'postmeta' for update in FROM clause
The query is here:
UPDATE postmeta
SET meta_value = 'visible'
WHERE meta_key = '_visibility'
AND post_id = ( SELECT post_id
FROM postmeta
WHERE meta_key = '_sku'
AND meta_value = 846635025502
LIMIT 1 )
Can anyone suggest what the issue is here. Thanks