I’m trying to run a UPDATE using REPLACE on my MySQL database.
I have a WordPress database table (wp_postmeta) containing four fields: post_id, meta_id, meta_key, meta_value.
I would like to REPLACE all instances of denticulata with heteropoda but only if that post (i.e. that row’s post_id) also has a row where the meta_key is genus and meta_value is Corydoras.
For instance,
post_id meta_id meta_key meta_value
4 14 breeding Some stuff here about breeding denticulata
2 15 breeding Some stuff here about breeding denticulata
4 16 genus Corydoras
2 17 genus Apistogramma
Only the row with meta_id of 14 should actually be altered there, as the rows with post_id of 2 aren’t from the Corydoras genus.
Is this possible? I have no idea where to start.
Thanks in advance,
Beware that this will also update
'denticulatas'with'heteropodas'(and any other words that include the stringdenticulata) and thatREPLACE()is case-sensitive, soDenticulatawill not be replaced.