May 26, 2005 at 3:20 am
Hello,
I have a logical expression and want to make it on sql. negation(negation(A) union negation(B))
A means serviceId = 1 & B means serviceId = 6
negation(A) means serviceId<>1
negation(B) means serviceId<>6
but I don't know how to make negation for the whole expression
Thank you beforehand
Zineb
May 26, 2005 at 4:26 am
Am I misunderstanding something here? As I understand it, negation(A) union negation(B) would return everything. Since negation(A) returns everything except those where serviceId=1 (including those with serviceId=6), and negationB returns everything except those where serviceId=6 (including those with serviceId=1), the union between these should return everything. And the negation of that then would be nothing. So I would eveluate the expression to nothing. But I am probably missing something here.
May 26, 2005 at 4:56 am
Hello Chris
Basically what I want is A interserction B which is A AND B. But in my case I can not do that because I can't write in the query "select propertyId where serviceId=6 AND serviceId=1". So I thought of an equivalent way to have A intersection with B, which is A AND B. I made 2 negations for A AND B and simplified the expression to negation ( negation(A) union negation(B)). I hope I'm clearer now. What do think?
Zineb
May 26, 2005 at 5:20 am
Is this what you want? Otherwise please post DDL and some sample data.
SELECT propertyId FROM tablename AS x
WHERE serviceId = 1
AND EXISTS (
SELECT * FROM tablename
WHERE serviceId = 6
AND propertyId = x.propertyId
)
On a side-note, SQL Server 2005 finally has the EXCEPT and INTERSECT relational operators.
May 27, 2005 at 4:07 am
Thank you very much Chris.
'EXISTS' worked for me yesterday but it's no more working today weird!
I used 'IN' instead and it's working fine now
Good luck
Zineb
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply