我有两个桌子。
route_info:(routeinfo_id(主键),route_src,route_dest,driver_id(外键)
route_details:(routedetails_id(主键),route_latitude,route_longitude,route_address,routeinfo_id(外键))。
在通过检查route_info表的某些约束试图将数据插入到route_details表中时遇到错误。
我的查询:
INSERT INTO route_details (route_latitude,route_longitude,routeinfo_id) VALUES (78.23,27.54,1)
SELECT *
FROM route_details
WHERE route_address='CNG Station,Agartala'
AND routeinfo_id IN (SELECT routeinfo_id
FROM route_info
WHERE route_info.route_source='Udaipur'
AND route_info.route_destination='Agartala'
and route_info.driver_id=1);