I'm trying to get a list of all the numbers for which the parent of that number and the parent of that numbers formers aren't the same.
Every number has a parent. A number can also have a forward( a number that was create before the current number was created) number and a former number( a number that was create after the current number was created).
The list of all the numbers is in the table other_table. The parent, former and forward numbers are in the parent_table.
This is what I came up with
select p.num, ps.former, ps2.former, ps3.former_pin
from ilrs.parent_table ps, ilrs.other_table p, ilrs.parent_table ps2, ilrs.other_table p2, ilrs.other_table p3, ilrs.parent_table ps3
where p.num = ps.forward
and ps.parent = 1
and p.num = p2.num
and p2.num = ps2.forward
and ps2.parent = 0
and p2.num = p3.num
and ps3.parent = 1
and ps3.former <> ps.former
and ps.former <> ps2.former
This is the result I get. Only the last field is changing and this goes on for many records 20000+ Is there a problem in the logic of my sql statment?
402010135 402017173 402017180 602004558
402010135 402017173 402017180 402012172
402010135 402017173 402017180 402002841
Thanks for taking a look at this.
Every number has a parent. A number can also have a forward( a number that was create before the current number was created) number and a former number( a number that was create after the current number was created).
The list of all the numbers is in the table other_table. The parent, former and forward numbers are in the parent_table.
This is what I came up with
select p.num, ps.former, ps2.former, ps3.former_pin
from ilrs.parent_table ps, ilrs.other_table p, ilrs.parent_table ps2, ilrs.other_table p2, ilrs.other_table p3, ilrs.parent_table ps3
where p.num = ps.forward
and ps.parent = 1
and p.num = p2.num
and p2.num = ps2.forward
and ps2.parent = 0
and p2.num = p3.num
and ps3.parent = 1
and ps3.former <> ps.former
and ps.former <> ps2.former
This is the result I get. Only the last field is changing and this goes on for many records 20000+ Is there a problem in the logic of my sql statment?
402010135 402017173 402017180 602004558
402010135 402017173 402017180 402012172
402010135 402017173 402017180 402002841
Thanks for taking a look at this.