Here's one way. Assumes that cust/item pairs are unique. select cust, sum((item='12a')+2*(item='13a')) as IND from transfile group by cust having IND=1;
Alternatively, you could build a temporary table with cust's who ordered 13a, the use a left join. > From: "Smith, Mike" <[EMAIL PROTECTED]> > To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]> > Subject: RE: How can I do this SQL query > Date: Thu, 23 May 2002 15:33:05 -0400 > > How can I do this SQL query > > I have a file(transfile) that has 2 fields(cust# and item#) > > CUST# ITEM# > 1 '12a' > 1 '13a' > 2 '12a' > 3 '13a' > 4 '15a' > > If I want to select customers that have ordered item '12a' but not '13a' > How can I do this? > > I want to end up with a result of only customer 2 in this case. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php