PDA

View Full Version : how to write a query question?


Tim Mousel
Fri 26th Jul '02, 2:59pm
Here is my query:

select products_id from products_to_categories where categories_id = 25

That gives me a list of 200 products_id. How do I then run a query on another table (products) to match products.products_id with the results of the query above?

Thanks,

Tim

WingMan
Wed 31st Jul '02, 8:56am
Try this ..


SELECT ptc.products_id
FROM products_to_categories ptc,
products p
WHERE ptc.products_id = p.products_id
AND ptc.categories_id = 25


link the two tables on a Key
-> WHERE ptc.products_id = p.products_id

you don't have to use an alias for the tables, it just saves some typing :rolleyes:

Tim Mousel
Tue 6th Aug '02, 2:25pm
Hello,

That worked perfectly. Thank you very much.

Tim

WingMan
Thu 8th Aug '02, 7:50am
Thankyou too for thanking me :)
I'm glad i could help