Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6329275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:37:42+00:00 2026-05-24T17:37:42+00:00

I have a wordpress database with a number of custom fields/metadata. ——— wp_postmeta ———

  • 0

I have a wordpress database with a number of custom fields/metadata.

---------
wp_postmeta
---------
post_id
meta_key
meta_value

I want to find all the posts with a meta_key of ‘Start Date’ and a value of ‘NOW()’, but not the posts that have the meta_key ‘Ongoing’ and value of ‘Yes’.

I’m a bit confused of how to join the queries:

SELECT * FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_postmeta.meta_key = 'Start Date'
AND wp_postmeta.meta_value > NOW()

with

SELECT * FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_postmeta.meta_key = 'Ongoing'
AND wp_postmeta.meta_value != 'Yes'

And potentially other queries… I think what is throwing me off is that I can’t add another WHERE clause to the statement? I think I just need a prod in the right direction because I am missing some basic mysql understanding.

Thank you so much in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:37:42+00:00Added an answer on May 24, 2026 at 5:37 pm

    Try this:

    SELECT * FROM wp_posts, wp_postmeta
    WHERE wp_posts.ID = wp_postmeta.post_id
    AND ((wp_postmeta.meta_key = 'Start Date'
    AND wp_postmeta.meta_value > NOW()) OR (wp_postmeta.meta_key = 'Ongoing'
    AND wp_postmeta.meta_value != 'Yes'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom table in my WordPress database named post_votes used for voting
i have a wordpress blog and want to give people the same user experience
I have a WordPress installation on my site, and I want to display WP
I have a wordpress database for accounts and settings (or for this example, joomla
I have a custom post type called song and i want to query the
I have basically MySQL dump from a WordPress database with some data. The whole
I am working in a MySQL database. I have added a custom field to
I have a custom made CMS system with a relatively small number (~1000) of
I have 2 tables (Wordpress Database), one which stores posts and the other post
I have WordPress instances with each in its own database. For an update I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.