mysql - WordPress SQL that updates custom post type meta values (older than 6 months) -


I have a custom post type (artwork), in addition to updating one and two meta_ values ​​in that process from 6 months There is also a need to update more (artwork) in which with Meta's (status) and Meta_View (available) and changes in (not available)

so for the first part I use 6 months Can return the old 'available' artwork;

  SELECT * wp207_posts` wp Join INNER `wp207_postmeta` at wm (wm.`post_id` = wp.`ID` and wm.`meta_key` = 'position' and wm.`meta_value `= 'Available' ') and DateDiff (NOW (),` post_date`) & gt; 182   

With these I need to update the values ​​of the following metadata;

  1. Update 'status' for 'not available' from
  2. Update price so that price can be removed (i.e. remove price price if
  3. Update 'price_range' so that the price is removed (i.e. remove the value_current value if it exists)

    The following SQL me 'status' 'Available' allows to update to 'not available'

      update `inside WP wp207_posts` join `wp207_postmeta` at wm (wm.` post_id` = wp.`ID` and wm.`meta_key` = 'position' and 'wm.meta_value` =' available ') and dATEDIFF (now () , `Post_data`) & gt; 182set`meta_value` = replacement (meta_value, '0', '1') where` meta_key` = 'position';   

    How do I know about removing a value for meta_key (see 2 and 3 above) using the same query - Artwork over 6 months old? For example, if I wanted to get value from all the artwork of 6 months of age, would it be the best way?

      Update `wp207_posts` include WP Insiders 'wp207_postmeta` at wm (wm.' Post_ id` = wp.`ID` and wm.`meta_key` = 'position' and wm.`meta_value `= '1') and DATEDIFF (now (),` post_data`) & gt; 182set`meta_value` = '' WHERE 'meta_key' = 'value';   

    I can confirm that all updates to this post should be done for me in the script - though doubtful is a better way.


    last SQL

      update wp207_postmeta wm wp207_posts wm.post_id = wp.id on wm set wm.meta_value = ' Not available 'wm.meta_key =' position 'and' wm.meta_value = 'available' and post_type = 'artwork' and statistics (now (), wp.post_date) & gt; 182; Update wp207_postmeta wp207_postmeta.meta_key IN ('price', 'price_range') and wp207_postmeta.post_id IN (wp207_posts wp select id where post_type = 'artwork' and dATEDIFF (NOW (), wp.post_date)> 182);   

    Thanks.

    try it

      update wp207_postmeta Wm wp207_posts wm.post_id = wp.id on wm.meta_value wm.meta_key = 'position' and where wm.meta_value = '=' is not available 'available' and dATEDIFF (now (), wp.post_date) Gt; 182; Where wp207_postmeta is removed from wp207_postmeta.meta_key ('value', 'PRICE_RANGE') and in (select wp207_posts id from WP where DateDiff (NOW (), wp.post_date)> 182) wp207_postmeta.post_id;    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -