Create Table as follows where column1 and column2 are both foreign key values.
ID|Column1|Column2|
0 | 1 | 1
1 | 1 | 2
2 | 1 | 2
3 | 2 | 2
I don's want duplicates as with row id #2 when I insert.
I thought I could insert as so:
INSERT INTO tablename (column1, column2) VALUES (@last_id_in_col1key,@last_id_in_column2key) <*>
Then I want something like this:
<*> where column1 and column2 are not equal to @last_id_in_col1key and @last_id_in_column2key
Is there a way to add this to my table or does it have to be a seperate command?
alter table tablename add unique index(column1, column2);