开发者

How to return rows that don't match another table?

开发者 https://www.devze.com 2023-03-03 11:55 出处:网络
I am using fluent nhibernate and nhibernate 3.1 and I am wondering how do I make a query to return results that don\'t match in another table.

I am using fluent nhibernate and nhibernate 3.1 and I am wondering how do I make a query to return results that don't match in another table.

Say I have 5 records from tableA and 3 records in tableB. Now 3 from TableA match the 3 from TableB.

So I want to return these 2 rows back as they where not in TableB. All the joins that I seen seem to look for matches and return t开发者_Python百科he matches. I want to basically return the differences.

if say I had 5 records from tableA and 100 in TableB but none of TableA's records matched any in TableB I want to return all of tableA's records.


Well I'm not sure that I'm answering the right question, your description seems a little fuzzy...

There's a couple of ways to go about this...

I guess the simplest and easiest way would be to use a SQL query:

string sqlQuery = "Select * from TABLENAMEA A where a.field not in (select b.field from TABLENAMEB b)"

results = (OBJECT) session.ExecuteSQL(sqlQuery);

Bear in mind that I'm doing that from memory, I know the facilities to do this exist... And probably won't take you more then a minute or two to figure out...

0

精彩评论

暂无评论...
验证码 换一张
取 消