|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple but useful technique - is it possible?[doesnt matter what the numbers are, as long as they are numbers] If I want to get a list of matching/non-matching numbers using a query, without creating any tables.... like: -- all numbers in g2 that match with g1 select * from (1,2,3) as g1 left outer join (2.3.4) as g2 where g1.something = g2.something and g2.something is null I hope the question makes sense..... Is it possible to do something like this....? (I did something like this a while ago... but can't remember what it is) I know this is anti-RDBMS... but I do a lot of 'ID'-matching to get needed ID's before generating any reports [cross check technique] Any help is appreciated, _Uday Some kind of school work?
Show quote "Uday" <U***@discussions.microsoft.com> wrote in message news:7CC65E2D-69A2-45B6-A6B2-188B6FF01E2F@microsoft.com... > Lets say, I have two groups of numbers (1,2,3,4,5...) and > (1,8,3,6,1,4,...) > [doesnt matter what the numbers are, as long as they are numbers] > > If I want to get a list of matching/non-matching numbers using a query, > without creating any tables.... > like: > > -- all numbers in g2 that match with g1 > select * > from (1,2,3) as g1 > left outer join (2.3.4) as g2 > where g1.something = g2.something > and g2.something is null > > I hope the question makes sense..... > > Is it possible to do something like this....? > (I did something like this a while ago... but can't remember what it is) > > I know this is anti-RDBMS... but I do a lot of 'ID'-matching to get > needed > ID's before generating any reports > [cross check technique] > > Any help is appreciated, > _Uday Not really a joke as you did not explain what you mean by « without creating
any tables ». Does the creation of a temporary table or local variable table or the use of a function that will return a table is permitted or if this is also out of question? And how are represented your groups of numbers (1,2,3,4,5...) and (1,8,3,6,1,4,...) ? As a long list of parameters or encoded in a string or what else? Show quote "Uday" <U***@discussions.microsoft.com> wrote in message news:E3EFF7D3-CE7F-42BE-8346-900EAAD4B425@microsoft.com... > good one..!! > [is that what my question sounds like..!! LOL..] The only structure in SQL is a table. So you will have to come up with a way
of representing your data as a relational table ( derived relation ) as: SELECT * FROM ( SELECT 1 UNION SELECT 2 UNION SELECT 3 ) g1 ( c ) LEFT OUTER JOIN ( SELECT 2 UNION SELECT 3 UNION SELECT 4 ) g2 ( c ) ON g1.c = g2.c WHERE g2.c IS NULL ; -- Anith |
|||||||||||||||||||||||