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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:47:07+00:00 2026-06-14T03:47:07+00:00

I have 2 tables, book and temp_table. There are 2 columns in book :

  • 0

I have 2 tables, book and temp_table.
There are 2 columns in book : book_id and tag_id, and only 1 column in temp_table (tag_id).

I need do selection used following rule:

  • If book has ALL the tags from temp_table, it will be in result.

For example, there are 3 books.

   First one has tag_id: 1,2,3,4.
   Second - 1,3,4
   Third - 1,2,3,5

And temp_table contains tag_id:1,3,4.

Needed selection has to contains 1st and 2nd books. 3d book must not be in result set because it has tag_id = 5, which there isnt in temp_table.

  • 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-14T03:47:08+00:00Added an answer on June 14, 2026 at 3:47 am
    select book_id
    from book b
    inner join temp_table t on t.tag_id = tag_id
    group by book_id
    having count(distinct tag_id) = (select count(distinct tag_id) from temp_table)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign
Ok i have 2 tables. A book table with the the primary key book_id
Let's say I have these sql tables: a) book b) customer c) borrow_history (book_id,
I have 3 tables: Book, Section and Content. I want to add many-to-many relation
I have 3 tables Student Loan Book - StudentID LoanID BookID which foreign keys
I have tree tables books bookmarks users where there is a n to m
I have two tables: BOOK BOOK_CODE TITLE PUBLISHER_CODE TYPE PRICE PAPERBACK --------- ----- --------------
Let say I have 3 tables: Book , Author and BookAuthor . Book has
Let's say I have two tables: Book and Category . Book has a foreign
I have two tables (in mysql) Book and BookPrice , BookPrice stores the prices

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.