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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query base on other table 1

Status
Not open for further replies.

pelagic

Programmer
Nov 7, 2002
97
US
Hi all,
I have Table1 which include the following:
Sub_Catagory Price
CAT 100
DOG 150
COW 200

Table2 has:
Sub_Catagory Price
CAT 110
CAT 50
CAT 200
DOG 175
DOG 200
DOG 100
COW 200
COW 250

How would I display data from Table2 base on the criteria given from Table1 where price is greater than price from Table1.
The result would be:
Sub_Catagory Price
CAT 110
CAT 200
DOG 175
DOG 200
COW 250

I have spent hours to look into this but I could not figured this out yet.
Any suggestion will help.

regards,
 
Create a Query using the SQL below. It should give the required result

Select Sub_Category,Price from Table2 INNER JOIN Table1 on Table2.Sub_Category=Table1.Category where Table2.Price > Table1.Price

Best of luck
 
Thanks MinusM,
It really works.
Thanks for the help.

If I change the prices on Table1 to 1000
and Table2 is mix, which include from 100 to 1500.
When I try to display only data from Table2 where prices is greater than prices from Table1. I still get prices smaller than 1000 from Table2? I don't know what causes this happend? Any hints will be Appreciated.

regards,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top