mysql - How can I uniquely Insert data into a table without using Unique/Primary key keyword in SQL? Is there any other way? -
i want insert data columns no data can inserted more once! no data of same type/category can same! know easier / best way use defining attribute unique / primary key ... there others ways this!
you can check data before inserting it, using group clause, or distinct or join. depends on requirement.
for example, if data identical , using distinct
enough:
insert <yourtable> select distinct ... ...
or directly check if data exists in table:
inset <yourtable> select .... table s not exists(select 1 yourtable t t.type = s.type , t.category = s.category)
and on..
Comments
Post a Comment