你可以做:
INSERT INTO table1 (start, stop)SELECt a.*FROM (SELECT 123456789 start, 234567890 stop) aLEFT JOIN table2 b ON (a.start,a.stop) IN ((b.start,b.stop))WHERe b.start IS NULL
其中
123456789和
234567890是分别用于
start和的输入值
stop。
然后,您可以根据所使用的数据库接口(PDO,mysqli等),使用rowCount或num_rows_affected对其进行检查。如果为0,则不插入任何记录,否则,发生插入。
SQLFiddle演示



