I am writting a SQL query , where I need to update the colouns in dummy coloumn with the value on the basis of same post_id such that for post_id '1' all the rows will have 'abc' in there dummy coloumn.
Similarly for the post_id '2' all the rows will have 'def' in the coloumn under dummy .
post_id |meta_key|dummy
1 url abc
1 link Null
1 key Null
1 data Null
2 url def
2 link Null
2 key Null
2 data Null
The query I tried is :
update <table_name>
set dummy = ( select meta_value
from <table_name>
where meta_key = 'url'
AND post_id = '1'
)
where post_id IN ('1') ;
This is working , but i want a dynamic query as i cant hardcode the post_id value as the data is like 10,000 post_ids.
The data after updating will look like this
post_id|meta_key|dummy
1 url abc
1 link abc
1 key abc
1 data abc
2 url def
2 link def
2 key def
2 data def
