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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:21:31+00:00 2026-06-11T00:21:31+00:00

I have a keywords and a categories table with an ID and a name

  • 0

I have a keywords and a categories table with an ID and a name col (I can’t merge them into a single table!)

There’s an articles table with ID, name, text.

And the many-to-many connection tables:

  • ckw for keywords, columns: key_id, article_id

  • ccat for categories, columns: cat_id, article_id

I can write a query to get those articles which belong to keywords ID 5 AND ID 7:

SELECT articles.name FROM articles
JOIN ckw ON (ckw.article_id = articles.id)
WHERE ckw.key_id IN (5, 7)
GROUP BY ckw.article_id
HAVING COUNT(ckw.key_id) = 2

But what if I want to get those articles which belong to keywords ID 5 AND ID 7, and also belong to category ID 12 AND ID 18? I can’t figure the right query out.

  • 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-11T00:21:33+00:00Added an answer on June 11, 2026 at 12:21 am
    SELECT articles.name
    FROM articles
    inner JOIN ckw ON ckw.article_id = articles.id
    inner join ccat on ccat.article_id = articles.id
    WHERE ckw.key_id IN (5, 7) 
    and ccat.category_id in (12,18)
    GROUP BY articles.article_id , articles.name 
    HAVING COUNT(distinct ckw.key_id) = 2 
    and count(distinct ccat.category_id) = 2 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a single textbox named Keywords. User can enter multiple strings for search.
I have a long list of categories and keywords provided by one client.Is there
I have to insert many product value records into an Oracle table. I get
I have a Keywords table with the fields KeywordsEn and KeywordsFr. I have another
I have a question about meta name and keywords: If I have more oages
I have a longer text and some keywords. I want to highlight these keywords
I have two tables that are related via a mapping table: keywords titles I
i have a keywords table,and i want to check a String contains keyword or
I have a database table that contain two fields Categories and Tags i need
I have keywords in table (for example texts table, key column). How to get

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.