I have two tables;
route_info: (routeinfo_id(primary key),route_src,route_dest,driver_id(foreign key)
route_details: (routedetails_id (primary key), route_latitude,route_longitude,route_address, routeinfo_id (foreign key)).
I am facing an error while trying to insert data into route_details table by checking some constraint of route_info table.
My query:
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);