How to find values which do not return any tuple in "IN" clause

2011-06-10 Thread Fahim Mohammad
Hi select * from tablename where fieldname in ('aaa','bbb','ccc','ddd'); return only the successful hit. How can I know how many out of four ('aaa','bbb','ccc','ddd') resulted in a miss OR which values do not return any tuple. Thanks Fahim

Re: How to find values which do not return any tuple in "IN" clause

2011-06-10 Thread Fayaz Yusuf Khan
On Saturday 11 Jun 2011 4:06:27 AM Fahim Mohammad wrote: > select * from tablename where fieldname in ('aaa','bbb','ccc','ddd'); > How can I know how many out of four ('aaa','bbb','ccc','ddd') resulted in a > miss OR which values do not return any tuple. Perhaps this would be what you're looking

Re: How to find values which do not return any tuple in "IN" clause

2011-06-10 Thread Fahim Mohammad
I am looking for those values (or count of those values) which do not resulted in a hit. Thanks Fahim On Fri, Jun 10, 2011 at 7:17 PM, Fayaz Yusuf Khan wrote: > On Saturday 11 Jun 2011 4:06:27 AM Fahim Mohammad wrote: > > select * from tablename where fieldname in ('aaa','bbb','ccc','ddd'); > >

Re: How to find values which do not return any tuple in "IN" clause

2011-06-10 Thread Nuno Tavares
create table dim (value varchar(10), primary key(value)); insert into dim values ('aaa'),('bbb'),('ccc'),('ddd'); SELECT tablename.fieldname FROM dim LEFT JOIN tablename ON tablename.fieldname = dim WHERE tablename.fieldname IS NULL; If this is not what intended, I'd suggest you to spend a littl

Re: How to find values which do not return any tuple in "IN" clause

2011-06-10 Thread Fahim Mohammad
Thank you all for prompt reply. I think there is no short cut and I may need to write nested query for doing this. The method suggested by you is not working. mysql> select * from city; +-+- +--+ | city_id | city_name| state_id | +-+- +

Re: How to find values which do not return any tuple in "IN" clause

2011-06-10 Thread Nuno Tavares
Fahim, I was not quite sure I understood you question, but looking at what you're trying to achieve in this example, give a try to my suggestion. You have to bear in mind that you can only GROUP BY values that indeed show up in the results. That means that if ('','y') never show up, they