Re: Select with normalized table

2004-09-22 Thread Philippe Poelvoorde
Johan Pettersson wrote: Hi Philippe, how about this: SELECTstrategyid, COUNT(marketid) cnt FROMstrategies_markets WHERE marketid in() GROUP BY strategyid ORDER BY cnt DESC; The resultset should contain the best matches, in descending order. To find strategies that contains all markets

Re: Select with normalized table

2004-09-21 Thread Johan Pettersson
Hi Philippe, how about this: SELECT strategyid, COUNT(marketid) cnt FROMstrategies_markets WHERE marketid in() GROUP BY strategyid ORDER BY cnt DESC; The resultset should contain the best matches, in descending order. To find strategies that contains all markets (but that may contain others

Select with normalized table

2004-09-21 Thread Philippe Poelvoorde
Hi, Here are the tables : CREATE TABLE markets ( Id integer NOT NULL auto_increment, ContractCode varchar(20), PRIMARY KEY (Id), ) TYPE=InnoDB; CREATE TABLE strategies ( Id integer NOT NULL auto_increment, StrategyCode char(15) NOT NULL DEFAULT '', PR