mysql - Combining two SQL queries to create an automatic procedure? -


I've visited this forum several times to find answers to my questions, but this is my first post. This is a specific question, so I was searching for what I was searching for.

My SQL is quite limited, I have just learned what I should do, as I have gone together, but it is well on my head!

I run a free pub advertising website - Our-Pub.co.uk. Pub can add your upcoming events to your individual pages along with a comprehensive pub guide. This is a completely free service, both pubs and pub hollers support

I use WordPress for my backend. Some added events are weekly / fortnightly events and I want to automatically publish them again. I was thinking that this can be done to investigate events by running a stored procedure and they are marked weekly / fortnightly by adding 604800 (or 604800x2) seconds.

At this time I have 2 SQL queries that I run, first to find all events marked as weekly or fortnight ...

  SELECT ID, post_title , wpr.object_id, wp_redhouseterms.name wp_redhouseterms to Join iNNER wp_redhouseterm_taxonomy wp_redhouseterms .term_id = wp_redhouseterm_taxonomy.term_id dusting Join wp_redhouseterm_relationships wpr.term_taxonomy_id = wp_redhouseterm_taxonomy.term_taxonomy_id ID = wpr.object_id inner wp_redhouseposts where classification = 'category' and wp_redhouseterms.term_id = 18 or wp_redhouseterms.term_id = 25 and post_type = 'post' order by `wpr` ._object_id`dessc   

This gives a list of those posts that are marked weekly / fortnightly with their post ID and whether they are weekly or fortnightly events. I can then use this list of post IDs in my next query to return the list of current ID time values ​​...

  SELECT meta_id, post_id, meta_value FROM `wp_redhousepostmeta` WHERE Like 'event_date_time' and 'post_id' ('post') like '1726' or post_id '2296' or post_id like '1655' or post_id like '2373' or '2371' or post_id '1650' or post_id like 'meta_key' Like '1652' or '3036' like Post_ID or 'Post_ID' 1580 'or' 2375 'like Post_ID or' Post_ID '4128' or 'Like' Oost_ID '4132' .... etc ....   

I am updating this list manually, weekly events or 604800 for fortnight events from 1206 600 By adding.

This was quite manageable at first but the list is increasing and now a real pain is going to be updated!

Any of you, the SQL Wizard, Advice how can I add these two scripts and to run at 3:00 p.m. To rigger, do I ask myself to update the events?

I have to go to myself, but there was no luck, honestly, I have lost!

Any help will be highly appreciated!

Thank you, Mark us - Pub.co.uk

Assume that 18 is weekly and 25 is fortnightly, the following should update the events appropriately:

  UPDATE wp_redhousepostmeta rh INNER JOIN ( SELECT ID, wt.term_id wp_terms wt INNER JOIN wp_term_taxonomy wtt wt.term_id = wtt.term_id INR wp_term_relationships wpr.term_taxonomy_id wpr.term_taxonomy_id wpr.term_taxonomy_id enter ID on inner wp_posts = wpr.object_id where classification = 'category' and ( Wt.term_id = 18 or wt.term_id = 25) and post_type = 'post') rh.post_id = t.ID at t SET rh.meta_value = rh.meta_value + cases When t.term_id = 18 THEN 604800 WHEN T Term_id = 25 THEN 1209600 end where rh.meta_key = 'event_date_time';   

Check it first by running the following and everything looks correct:

  SELECT t.id, t.term_id, rh.meta_value, rh.meta_value + Case when TTR_ID = 18 THEN 604800 WHEN t.term_id = 25 THEN 1209600 END as new_meta_value wp_redhousepostmeta Join R Inner (SELECT ID, wt.term_id wp_terms wt INNER JOIN wp_term_taxonomy wtt.term_id = wtt.term_id INNER JOIN Wp_term_relationships wpr.term_taxonomy_id = wtt.term_taxonomy_id enter wp_posts on INNER id = wpr.object_id WHERE classification = 'category' and (wt.term_id = 18 or wt.term_id = 25) and rhi on post_type = 'post') Post_id = T.ID WHERE rh.meta_key = 'event_date_time'   



Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -