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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:57:37+00:00 2026-05-20T18:57:37+00:00

I have the following tables: CATEGORIES — entry_id, cat_id TITLES — entry_id, title DATA

  • 0

I have the following tables:

CATEGORIES —
entry_id, cat_id

TITLES — entry_id, title

DATA — entry_id, date, body

For each record entered into the DB the same entry_id is entered into all three entry_id fields in the three tables. In the Categories table, it will post a record for each category I’ve such as:

entry_id: 100 cat_id:24

entry_id: 100 cat_id:31

entry_id: 100 cat_id:17

(say cat_id 24 is web_design, 31 is coding and 17 is ajax)

THE PROBLEM: I’m having a bugger of a time selecting only records that have a record for BOTH cat_id 24 and 17 in the Categories table along with other fields. Here’s what I’ve got. I know it’s crude but it gets me almost all the way there:

SELECT 
    data.entry_id,
    data.date,
    data.body,  
    titles.entry_id,
    titles.title AS biz_name,
    categories.entry_id,
    categories.cat_id
    FROM data, titles, categories
    WHERE data.entry_id = titles.entry_id 
    AND data.entry_id = categories.entry_id 
    AND categories.cat_id = '24'

This will display everything with a cat_id of 24 but when I add

AND categories.cat_id = '17'

to the very end of the query, nothing is returned.

Any thoughts?

  • 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-20T18:57:38+00:00Added an answer on May 20, 2026 at 6:57 pm
    SELECT 
    data.entry_id,
    data.date,
    data.body,  
    titles.entry_id,
    titles.title AS biz_name,
    FROM data
    JOIN titles ON data.entry_id = titles.entry_id
    INNER JOIN categories cat1 ON data.entry_id = cat1.entry_id AND cat1.cat_id=17
    INNER JOIN categories cat2 ON data.entry_id = cat2.entry_id AND cat2.cat_id=24
    WHERE ((cat1.cat_id) = (17)) AND ((cat2.cat_id) = (24))
    

    This new query correctly filters for only the ones with both

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

Sidebar

Related Questions

I have the following tables: CREATE TABLE title ( booktitle VARCHAR( 60 ), title_id
I have inherited a web app with the following tables: Categories, SubCategories and Pages.
I have the following tables (condensed for readability): Call ID CallerName CallerTime Categories ID
I have tables with listings, categories and one that maps them to each other.
I have the following tables: Categories ================================= CategoryID | ParentID | Text --------------------------------- 1
I have the following table: categories: cat_id | cat_cat | cat_name 1 | 0
I have the following tables in a PostgreSQL: Categories | Locations | Checkins |
I have the following tables: Table categories { -id- -name- 1 Action 2 Comedy
I have the following two tables that record expenditure and provide expenditure category information:
I have the following tables: Products Categories Subcategories Brands with the following fields: Products:

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.