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 6530569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:46:17+00:00 2026-05-25T09:46:17+00:00

I’m trying to search by three conditions under WordPress wp_usermeta table which is like

  • 0

I’m trying to search by three conditions under WordPress wp_usermeta table which is like below:

      umeta_id  user_id   meta_key  meta_value       
            49  3   email   schodde.virginia@saugov.sa.gov.au
        51  3   suburb  Noarlunga
        52  3   state   SA
        53  3   postcode    5168
        54  3   maternitybg Yes
        55  3   occupation  Comm midwife
        56  3   wp_user_level   0
        57  3   nick_name   Virginia
        58  3   last_name   Schodde
        59  3   first_name  Virginia
        60  3   title    
        61  3   country  
        63  3   isinstructor     
        64  3   gender   
        65  3   idf_indig_tsi    
        66  3   idf_ct_ld    
        67  3   comments     
        68  3   action   
        69  3   user_id 3
        70  3   submit  Save
        72  3   traininglocation    Adelaide
        46980   3   workplace   Noarlunga Health service
        45304   3   trainingdate    22/03/2005
        48658   3   contact_no  0883849673
        43616   3   wp_capabilities a:1:{s:10:"subscriber";s:1:"1";}
        41939   3   maternitybg Yes

Below is my current SQL but it’s not filtering by postcode 3000:

    select distinct user_id from wp_usermeta where 
( meta_key='state' and meta_value= 'Vic') or 
( meta_key='postcode' and meta_value= '3000') or 
( meta_key='maternitybg' and meta_value= 'No') 
GROUP BY user_id HAVING COUNT(meta_key) = 3

Any ideas?

  • 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-25T09:46:18+00:00Added an answer on May 25, 2026 at 9:46 am

    User number 3 has two rows for the maternitybg = Yes key, so this matches:

    having count(meta_key) = 3
    

    To fix this, add distinct to verify that it matches three different keys:

    having count(distinct meta_key) = 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

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.