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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:48:05+00:00 2026-05-28T07:48:05+00:00

I just asked this question Multiple Where conditions , but realised there was more

  • 0

I just asked this question Multiple Where conditions, but realised there was more to it (and didn’t want to confuse the other question).

I have a table that looks like this:

meta_id - id - meta_key     - meta_value
1         1    school         Some School 1
2         2    school         Some School 2
3         2    hidden         1
4         3    school         Some School 3
5         4    school         Some School 4
6         5    school         Some School 5
7         5    hidden         1

Thanks to my previous question I have this syntax:

SELECT DISTINCT m1.id 
FROM metadata m1
join metadata m2 on m1.id = m2.id
WHERE (m1.meta_key = 'school' AND m1.meta_value = 'Some School 1') 
AND (m2.meta_key = 'hidden' AND m2.meta_value = '1')

which finds the id if the school = Some School 1 and hidden = 1

But the problem is that the row hidden is only there if it is hidden, it doesn’t exist if its not hidden – so its not as easy as hidden = 0 means its not hidden and hidden = 1 means its hidden.

So I need to find out school = Some School 1 and that for the same the id, the row hidden doesn’t exist.

  • 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-28T07:48:06+00:00Added an answer on May 28, 2026 at 7:48 am
    SELECT DISTINCT m1.id 
    FROM metadata m1
    WHERE 
        m1.meta_key = 'school' 
    AND m1.meta_value = 'Some School 1' 
    AND NOT EXISTS 
    (
      SELECT * FROM metadata m2
      WHERE 
          m2.meta_key = 'hidden' 
      AND m2.meta_value = '1'
      AND m2.Id = m1.Id
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just asked this question an hour ago but with regards to IE8
My apologies, I've actually asked this question multiple times, but never quite understood the
I asked this question earlier, but I'm missing one important thing. I have a
I know this question has been asked multiple number of times and i have
While I have seen this question asked, I haven't seen the answer. I just
I know this question has been asked multiple times, but nobody has been able
The question has been asked multiple times, but this is not a repeat. I
I just asked this question . Which lead me to a new question :)
I asked this question yesterday, and at the time it was just what I
I know this has been asked thousands of times but I just can't find

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.