我有一个表名课程。它包含以下数据:
mca
bca
msc
me
现在当我一次输入mca mtech的2个值时。它应该接受mtech并忽略mca。请任何人帮忙解决。
Field Type Collation Attributes Null Default Extra Action
id int(15) No None AUTO_INCREMENT Browse distinct values Change Drop Primary Unique Index Fulltext
register_number varchar(255) latin1_swedish_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
name varchar(255) latin1_swedish_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
course_code varchar(255) latin1_swedish_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
subject_code varchar(255) latin1_swedish_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
exam_name varchar(255) latin1_swedish_ci No None Browse distinct values Change Drop Primary Unique Index Fulltext
答案 0 :(得分:1)
使用类似的东西:
INSERT INTO TABLE1(column1, column2, ...
VALUES value_for_column1, value_for_column2, ...
WHERE NOT EXISTS (SELECT * FROM TABLE1 WHERE column1 = value_for_column1)