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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:41:00+00:00 2026-06-03T13:41:00+00:00

OK I have two sql tables I need to query from which are product

  • 0

OK I have two sql tables I need to query from which are product and product_to_category

product looks like

enter image description here

product_to_category looks like

enter image description here

I am trying to query both the tables so that I can select all that are in a certain category number, which is in product_to_category, but also select all that have a status of 1, which determines if they are active or not. I am trying to do this in a single query, and so far my query looks like what is below, problem is that I am not sure how to match the product_id‘s together to work how I would like. Can someone give me an idea of how to do this?

mysql_query("SELECT * FROM product,product_to_category WHERE product.status = 1 AND product_to_category.category_id = 35 ORDER BY product.sort_order ASC")
  • 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-03T13:41:02+00:00Added an answer on June 3, 2026 at 1:41 pm

    Try this:

    mysql_query("SELECT * FROM product JOIN product_to_category ON (product.product_id = product_to_category.product_id) WHERE product.status = 1 AND product_to_category.category_id = 35 ORDER BY product.sort_order ASC")

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

Sidebar

Related Questions

I have to generate a single sql query, which retrieves two columns from two
I have Two Many-To-Many tables which I need to write a Entity Framework Linq
I have 3 tables on which i need to select data from using ms-access
I am trying to use a prepared statement that deletes from two (temporary) tables:
I have a SQL query (MS Access) and I need to add two columns,
I have two SQL Server tables with Primary Keys (PK) and a Foreign Key
I have two identical SQL Server tables ( SOURCE and DESTINATION ) with lots
I am working on PHP and database MySQL. I have two tables in SQL
We have two tables in a SQL Server 2005 database, A and B.There is
I have two tables Team_DATA and Driver_PROFILE_DATA in an SQL database. For every driver_profile

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.