mysql format :
mysql格式:
jcid_no die_no qty
jcid-085951 12345 2
jcid-085951 12345 2
Friends I've a table format as the above , I'll be continuously inserting the values into the table but my requirement is I can insert n times same number of same jcid_no and die_no but not on the same row .
朋友我有上面的表格格式,我会不断地将值插入到表中,但我的要求是我可以插入n次相同数量的相同jcid_no和die_no但不能插入同一行。
Valid example:
jcid_no die_no qty
jcid-085951 12345 2
jcid-085951 54321 2
jcid_no die_no qty
jcid-085951 12345 2
jcid-984301 12345 2
Same jcid_no different die_no and same die_no different jcid_no is ok but as if now my table got cluttered by have same table values multiple times my requirement is first I have to delete all the duplicate values that has been already inserted (i.e)
相同的jcid_no不同die_no和相同的die_no不同jcid_no是好的,但好像现在我的表混乱了多次具有相同的表值我的要求是首先我必须删除已经插入的所有重复值(即)
Wrong Format :
格式错误:
jcid_no die_no qty
jcid-085951 12345 2
jcid-085951 12345 2
and the second thing is preventing this duplication for further enter , I use PHP as my front end .
第二件事就是防止这种重复进一步输入,我用PHP作为我的前端。
1 个解决方案
#1
1
To avoid further faulty values try using combined primary key like
要避免进一步的错误值,请尝试使用组合主键
PRIMARY KEY (jcid_no, die_no)
To delete double values try it with self join delete.
要删除双值,请尝试使用自联接删除。
#1
1
To avoid further faulty values try using combined primary key like
要避免进一步的错误值,请尝试使用组合主键
PRIMARY KEY (jcid_no, die_no)
To delete double values try it with self join delete.
要删除双值,请尝试使用自联接删除。