I have been working on this one for quite some time and I haven't been able to crack it. Lots of solutions for mysql 4.1 and later but having to work with 4.0 🙁
None of the queries I have found or examples in books and online are quite the same as my problem. Have also tried using subqueries /exists but no luck there either.
The three tables in question are:
product_market_id - (product_id, market_id) all products can have multiple market_ids so is a combined primary key.
product_textile_category - (product_id, textile_category_id) products can belong to multiple textile categories
product - (product_id, product_name etc)
I am trying to write a query that selects the product_ids that have a particular market_id, and a particular textile_category_id.
MY ATTEMPT THUS FAR:
$query = "SELECT product_textile_category.product_id
FROM product_textile_category, product_market_id
WHERE product_textile_category.product.id = product_market_id.product_id
AND product_textile_category.textile_category_id = '".$textile_category_id."'
AND product_market_id.market_id = '2'";
It is 3am in the morning and I'm trying to meet a deadline of tomorrow morning for a go live.....head swimming....must practise sql, must practise sql
Many thanks in advance for any pointers.