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

  • Home
  • SEARCH
  • 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 4624248
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:06:11+00:00 2026-05-22T03:06:11+00:00

I have two tables sturctured like so: Posts Table id content Meta Table id

  • 0

I have two tables sturctured like so:

Posts Table
id
content

Meta Table
id
post_id
content
name

The posts table is the main parent that can have data from the meta table joined with it

Post Table
id   content
1    My first row

Meta Table
id   post_id  content   name
4    1        2011-5-5    date
5    1        My Heading  heading
6    2        2012-3-3    date
7    2        My Title    heading

How would I write a query to search for an entry in the posts table that contains meta data content of 2011-5-5 with a name of date and My Heading with a name of heading

I can get them individually

Select *
from posts, meta
WHERE post_id = posts.id
   AND (name='date' AND content='2011-5-5')

But as soon as I add a second criteria, it returns zero results, becuase we are asking the name field to be two different things

Select *
from posts, meta
WHERE post_id = posts.id
   AND (name='date' AND content='2011-5-5') 
   AND (name='heading' AND content='My Heading')

Any help would be greatly appreciated, Thanks!

  • 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-22T03:06:12+00:00Added an answer on May 22, 2026 at 3:06 am

    You’ll need to join to the table twice:

    SELECT *
    FROM posts, meta m1, meta m2
    WHERE posts.id=m1.post_id
    AND posts.id=m2.post_id
    AND m1.name="date" AND m1.content="2011-5-5"
    AND m2.name="heading" AND m2.content="My Heading"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, like so: table a contains: id|name stock1|fullname stock2|fullname2 stock3|fullname3 table
I have two tables that look as Follows: Person (Table Name) Name1/Phone1/Email1/Address1/Organization1/Notes1 (Fields) Organization
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two tables, structured like so: table A: A_ID varchar(32) PRIMARY KEY field1
I have two SQL tables with data that I would like to compare. The
I have two tables structured like this: table a id title date 1 testing1
I have two tables that are joined together. A has many B Normally you
We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have two tables say, t1 and t2 that have t1.t1_id and t2.t2_id as

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.