I am trying to get all my post where Vote IPAddress doesnt match mine own. Here is my SQL. The problem is, i get the post i voted for when someone else also voted for it. I thought this code says select post when left join is possible and there are no IPAddr which == mine. But that doesnt seem to be happening. How do i write this?
select * from Post
left join Vote as V on V.post=Post.id AND V.IPAddr<>123
where flag='1';
Here is some dummy data to illustrate the problem.
create table P(id int primary key, body text);
create table V(id int primary key, val int, ip int, post int);
insert into P values(1,"aaa");
select * from P left join V on V.post=P.id where (V.ip is null or V.ip<>123);
insert into V values(1, 2,123,1);
select * from P left join V on V.post=P.id where (V.ip is null or V.ip<>123);
insert into V values(2, 2,13,1);
select * from P left join V on V.post=P.id where (V.ip is null or V.ip<>123);