SQLite unique column based on foreign key -


this question has answer here:

i have table this:

create table a(     _id integer primary key,    name integer,    message integer unique ); 

message column must unique when name columns same. how can achieve that?

example:

insert a(name, message) values (1, 5) 

this must throw error:

insert a(name, message) values (1, 5) 

this must work:

insert a(name, message) values (2, 5) insert a(name, message) values (1, 6) 

thanks in advance.

you can set column unique click icon unique in tables list

alter table table_name add constraint constr_id unique (user_id, game_id, date, time) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -