x404.co.uk http://www.x404.co.uk/forum/ |
|
SQL Query Query http://www.x404.co.uk/forum/viewtopic.php?f=4&t=16119 |
Page 1 of 1 |
Author: | jonlumb [ Thu Mar 22, 2012 10:10 am ] |
Post subject: | SQL Query Query |
I have a table which contains two columns, one called Dealers, one called Brands. Any entry in the table represents a dealer stocking a given brand. What I'm trying to get is a SQL query that allows be to list each dealer that stocks all of a given selection of brands, rather than just returning each dealer that stocks at least one of the aforementioned brands. Anyone got any ideas? |
Author: | finlay666 [ Thu Mar 22, 2012 10:59 am ] |
Post subject: | Re: SQL Query Query |
Group by the dealer, return where each item in the subset is there as a c# linq statement (may need some tweaking) string[] brands = new string[]{"foo","bar"}; var foo = from t in table group t by t.Dealer into tDeal where(t.select(p=>p.Brands).Intersect(brands)); |
Author: | tombolt [ Thu Mar 22, 2012 1:03 pm ] |
Post subject: | SQL Query Query |
Am I being thick here or isn't the query just select dealer where brand = abc and def and etc? |
Author: | finlay666 [ Thu Mar 22, 2012 1:35 pm ] | |||||||||
Post subject: | Re: SQL Query Query | |||||||||
it is, but as (possibly) a more programmatic approach |
Author: | jonlumb [ Thu Mar 22, 2012 2:23 pm ] | |||||||||
Post subject: | Re: SQL Query Query | |||||||||
Apparently not, having just tried it. Will have a look at the Group By function later. Edit: Or maybe I was just being an idiot; it's now working. Sorry for the dumb questions, it's been a while since I used any SQL. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |