I have a table that has two columns to store id from another table. Column1 gets id from ABC table and Column2 also gets id from that table but letter is called parent ID, so with this information I know who is parent of who.
Now I want to create a constraint not to ever let both columns to get same id. The following did not work:
ALTER TABLE id_parent_table
ADD CHECK (parent_id != main_id)
This is still allowing to insert two identical numbers.