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

  • Home
  • SEARCH
  • 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 6652339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:07:29+00:00 2026-05-26T01:07:29+00:00

my title may not explain what I am looking for, this is my current

  • 0

my title may not explain what I am looking for, this is my current query for pulling in products for a shop:

mysql_query("SELECT * FROM Items 
             WHERE ((Items.menu_id='$menu_id' AND Items.status='1') 
                   $colour_sql) 
             $order_sql 
             LIMIT $lim_from,$limit_per_page");

The part where it says $colour_sql I want to have somthing that says:

AND (Items.id=colour.product_id AND colour.colour='pink')

So it only show products that are pink, with the colours being in a seperate table. I have searched for answers, but I can’t seem to find one explaining my situation, maybe its because I don’t know exactly what i’m, looking for, any help is appreciated thanks.

  • 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-26T01:07:30+00:00Added an answer on May 26, 2026 at 1:07 am

    If you want to join with table colour you need to do either a join or a subselect.

    Join

    $menu_id = mysql_real_escape_string($menu_id);
    mysql_query = "SELECT i.* 
      FROM items i
      INNER JOIN colour c ON (c.product_id = i.id)
      WHERE i.menu_id = '$menu_id' 
        AND i.status = '1'
        AND c.colour = 'pink'
      ORDER BY .....
      LIMIT {intval($limit_per_page)} OFFSET {intval($lim_from)} ";
    

    Subselect

    $menu_id = mysql_real_escape_string($menu_id);
    mysql_query = "SELECT i.* 
      FROM items i
      WHERE i.menu_id = '$menu_id' 
        AND i.status = '1'
        AND i.id IN (SELECT c.product_id FROM colour c WHERE c.colour = 'pink')
      ORDER BY .....
      LIMIT {intval($limit_per_page)} OFFSET {intval($lim_from)} ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The title may not really explain what I'm really trying to get at, couldn't
May be my title is not clear. I am looking for some kind of
ok not as simple as title may make it sound. I tried this in
Ok, the title may not be the most descriptive. It's easier to explain with
This title may seem strange, so let me try to explain what I'm trying
Ok Title may not be clear so let me explain. I have 2 classes,
this title may not best describe my problem. I'm using Netbean GUI builder to
the post title may not explain fully, but here is what I am hoping
The title of this question is not very clear but I cannot explain what
That title may need some work. Perhaps after reading this, you may be able

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.