postgresql - 通过检查 Postgresql 中另一个表的某些约束来将数据插入到表中
问题描述
我有两张桌子;
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);
解决方案
推荐阅读
- postgresql - 目标表未正确更新
- javascript - 如何找到最长子串的长度?
- javascript - 验证数组中的每个项目与同一数组中的其余元素进行比较
- python - Polar (Windrose) yticklabel 对齐
- typescript - 如何在Javascript中的匿名回调函数中获取回调的引用
- java - 建议:绕过 WebLogic t3
- python - *** _pickle.UnpicklingError:pickle 数据被截断
- angular - ngFor中带有异步变量的过滤函数
- ignite - ignite:什么是每周时间序列查询?
- regex - 正则表达式 - .htaccess GET 请求的格式化 url