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

[eluser]nevsie[/eluser]
Right, sorry, said I would be back!!!
I have everything working and in principle it does as you suggested, however the IN part of the query does not perform as i wished (and most likely i did not explain correctly above)...

As far as i have read, IN will pull back all rows which have ANY of those values in it... (effectively and OR on each of those values). Therefore using my example from above:
Code:
prod_id     cat_id
  1         123
  2         123
  3         123
  4         123
  1         125
  2         126
  3         126
  5         127
cat_ids “123” and “125” using an IN would return "1", "2", "3", "4"
cat_ids “123” and “127” using an IN would return "1", "2", "3", "4", "5"

Where as i really wanted an AND where which only returns a distinct prod_id if both cat_ids are met...
cat_ids “123” and “125” wanted results "1"
cat_ids “123” and “127” wanted results "no results"

Does this make more sense? will have a look and play around with the subquery as i am only ever going to have two Cat_ids in this current instance...
Hope you can offer a magic solution, i am getting tired eyes now!!! And you help is truly 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