Welcome Guest, Not a member yet? Register   Sign In
SQL question / advice
#1

[eluser]nevsie[/eluser]
I wondered if any one could offer advice on how to solve a scenario... Its confusing me, and a little beyond my abilities (if it is possible!)...

I have a single table which holds product_ids and category_ids... Simple theory is that a product can be put in more than one category... no problem there...

However, i want to run a search query which returns only product_ids that in two defined categories... for example:

Code:
prod_id     cat_id
  1         123
  2         123
  3         123
  4         123
  1         125
  2         126
  3         126

If i want only product ids that are in categories "123" and "125" i would then be returned "1".
If i wanted "123" and "126" i would be returned "2" and "3"

Can anyone advise me on how and if this will be possible through a (single) SQL query? I am currently working on queries, subqueries, join, union, etc. trying to figure out a possibility... my mind is frying!!!
Help appreciated, N


Messages In This Thread
SQL question / advice - by El Forum - 10-23-2008, 12:06 PM
SQL question / advice - by El Forum - 10-23-2008, 01:11 PM
SQL question / advice - by El Forum - 10-23-2008, 01:20 PM
SQL question / advice - by El Forum - 10-23-2008, 01:24 PM
SQL question / advice - by El Forum - 10-23-2008, 01:47 PM
SQL question / advice - by El Forum - 10-23-2008, 01:53 PM
SQL question / advice - by El Forum - 10-23-2008, 01:56 PM
SQL question / advice - by El Forum - 10-23-2008, 02:25 PM
SQL question / advice - by El Forum - 10-23-2008, 07:50 PM
SQL question / advice - by El Forum - 10-24-2008, 02:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB