Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a simple query 1

Status
Not open for further replies.

rvr1

Programmer
Joined
Feb 6, 2004
Messages
16
Location
NL
Hi,

This is my first real project using mysql and PHP and would like some help creating a query please.

I have two tables:

Table 1 [product_id, product_desc, product_cost]

Table 2 [brand_id, category_id, product_id]

What I want to do is search table 2 for entries where the brand_id and category_id meet certain criteria.

Then I wish to extract the list of product_id's and use these to pull out the product_desc and product_cost from table 1 where the product_id matches the results of the search.

I hope that makes sense. Appologies if this appears overly simple to some people - as I said, it's my first attempt!

Thanks :o)
 
Code:
select product_desc, product_cost
from   table1, table2
where  table1.product_id = table2.product_id
and    brand_id = <criterion>
and    category_id = <criterion>;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top