i trying figure out how insert data second table first table, don't want insert existing data second table had previous injection. there anyway check before inserts data?
here have far:
//get connection require_once('connect.php'); //copy data table $query = mysqli_query($con, "insert content2 (d1, d2, d3) select d1, d2, d3 content"); mysqli_close($con); i tried put "limit 1" query, didn't work. i'm not sure if had in right place...
you can have database verify data unique. instance, if triple of d1, d2, d3 supposed unique, create unique index/constraint on columns:
create unique index idx_content2_d1_d2_d3 on content2(d1, d2, d3); then if try insert row, you'll error. can around error using on duplicate key update:
insert content2(d1, d2, d3) select d1, d2, d3 content on duplicate key update d1 = values(d1); the update doesn't change values. prevents error occurring.
Comments
Post a Comment