I am trying to find a query like this. Is it possible in MySQL?
ALTER TABLE `table1`
ADD CONSTRAINT my_constraint_name
FOREIGN KEY (some_id, some_other_id) REFERENCES `table2`(id, other_id);
My scenario is, table1.some_id should be referred to table2.id Where it should also meet table1.some_other_id is from the same row of table2 and that is table2.other_id
Emil Moe
Senior Data Engineer
I'm not sure why you would refer to 2 columns in same table. But it is possible, I think you can do it with 2 times ADD CONSTRAINT