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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:13:18+00:00 2026-06-14T23:13:18+00:00

tag tag_id tag post_id ——————————– 1 category1 1 2 category2 1 3 etc 2

  • 0

tag

tag_id      tag          post_id 
--------------------------------
1           category1    1
2           category2    1
3           etc          2
4           category3    1

post

post_id title
-------------
1       title1

How can we get title1 because its in the tag category1 && category2

something like

SELECT TITLE 
  FROM post, tag 
 WHERE tag.post_id = post.post_id 
   AND tags.tag = 'category1','category2'
  • 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-06-14T23:13:20+00:00Added an answer on June 14, 2026 at 11:13 pm

    In order to check if a title has BOTH ‘category1’ and ‘category2’, you can use the following SQL query:

    SELECT title 
    FROM post 
    JOIN tag ON post.post_id = tag.post_id 
    WHERE tag.tag_id IN (SELECT tag_id FROM tag WHERE tag = 'category1')
    AND tag.tag = 'category2';
    

    To check for other categories you just repeat the WHERE clause:

    SELECT title 
    FROM post 
    JOIN tag ON post.post_id = tag.post_id 
    WHERE tag.tag_id IN (SELECT tag_id FROM tag WHERE tag = 'category1')
    AND tag.tag_id IN (SELECT tag_id FROM tag WHERE tag = 'category2')
    AND tag.tag = 'category3';
    

    This would return results for titles that have all 3 categories.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 tables POST: id POST_TAG: post_id tag_id value TAG: id SEARCH: tag_id
how can i get the number from a div tag's id? example: <div id=button1></div>
post (id_post, title) tag (id_tag, name) post_tag (id_post_tag, id_post, id_tag) Lets suppose that id_post
If I have 3 tables: posts post_id title body tags tag_id name posts_tags post_id
i have this 4 tables: posts{id,post,date} comment{id, user_id,post_id, comment, date} tag_post{tag_id,post_id} users{user_id, email,pwd,username} i
I have the following tables: Post (id, title, author_id) etc Tags Post_tags Author The
TAGS tag_id post_id value ------------------------ 1 1 some 2 1 good 3 1 title
I have the models User, Post, Comment and Tag. User creates Post. Posts can
I have three tables: tbl_tag tbl_post tbl_post_tag(post_id, tag_id) tbl_users . Each Post has multiple
How do I get a button with the a specifyed tag id like to

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.