Home › Forums › General Issues › How can I query on the postmeta table for two keys › Reply To: How can I query on the postmeta table for two keys
Is there a better way to get this or do I simply have to run the update three times. The issue is that 3 of the columns I need are in the meta_key value.
[Add most of the info from post and also Venue]
INSERT into wp_venue_title_startdate (post_id, meta_post_id, post_author, post_title, meta_venue, post_type, post_status)
SELECT p.id, m.post_id, p.post_author, p.post_title, m.meta_value,p.post_type,p.post_status
FROM wp_posts p, wp_postmeta m
WHERE m.post_id=p.id AND m.meta_key=”venue” AND p.post_status=”publish”;
[Add User Name]
UPDATE wp_venue_title_startdate tbl_sd
INNER JOIN wp_users u
ON tbl_sd.post_author = u.id
SET tbl_sd.user_login=u.user_login
[Add Start Date]
UPDATE wp_venue_title_startdate tbl_sd
INNER JOIN wp_postmeta m
ON tbl_sd.post_id = m.post_id
SET tbl_sd.meta_start_date=m.meta_value
WHERE m.meta_key=”start_date”
[Add END Date]
UPDATE wp_venue_title_startdate tbl_sd
INNER JOIN wp_postmeta m
ON tbl_sd.post_id = m.post_id
SET tbl_sd.meta_end_date=m.meta_value
WHERE m.meta_key=”end_date”
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.