mysql多表联合查询返回一张表的内容实现代码
2019/6/30 18:47:11
本文主要是介绍mysql多表联合查询返回一张表的内容实现代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
今天在使用mysql语句的时候老是报错,语句如下:
Sql代码
SELECT sapcle FROM SellEnterpriseBaseInfor sebie,SellEnterpriseBaseInforVer sebive,SellApplyPermitChangeList sapcle
WHERE 1=1 AND sebie.iVerID = sebive.id AND sapcle.iEnterpriseBaseInforID=sebive.id AND sapcle.iState=1 AND sapcle.iEnterpriseID=11027516 AND sapcle.id=84
在consol控制台,查询到hibernate打印出来的sql语句,拿到mysql里面查询的时候老是报错,提示Unknown column 'sapcle' in 'field list',按照后面定义的 SellApplyPermitChangeList sapcle应该已经没问题了,问了同事才发现,在java语句里面可以这么写,但是在mysql编辑器里面使用的时候要改成
Sql代码
SELECT sapcle.* FROM SellEnterpriseBaseInfor sebie,SellEnterpriseBaseInforVer sebive,SellApplyPermitChangeList sapcle
HERE 1=1 AND sebie.iVerID = sebive.id AND sapcle.iEnterpriseBaseInforID=sebive.id AND sapcle.iState=1 AND sapcle.iEnterpriseID=11027516 AND sapcle.id=84
Sql代码
复制代码 代码如下:
SELECT sapcle FROM SellEnterpriseBaseInfor sebie,SellEnterpriseBaseInforVer sebive,SellApplyPermitChangeList sapcle
WHERE 1=1 AND sebie.iVerID = sebive.id AND sapcle.iEnterpriseBaseInforID=sebive.id AND sapcle.iState=1 AND sapcle.iEnterpriseID=11027516 AND sapcle.id=84
在consol控制台,查询到hibernate打印出来的sql语句,拿到mysql里面查询的时候老是报错,提示Unknown column 'sapcle' in 'field list',按照后面定义的 SellApplyPermitChangeList sapcle应该已经没问题了,问了同事才发现,在java语句里面可以这么写,但是在mysql编辑器里面使用的时候要改成
Sql代码
复制代码 代码如下:
SELECT sapcle.* FROM SellEnterpriseBaseInfor sebie,SellEnterpriseBaseInforVer sebive,SellApplyPermitChangeList sapcle
HERE 1=1 AND sebie.iVerID = sebive.id AND sapcle.iEnterpriseBaseInforID=sebive.id AND sapcle.iState=1 AND sapcle.iEnterpriseID=11027516 AND sapcle.id=84
这篇关于mysql多表联合查询返回一张表的内容实现代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-15一文看完MySQL 9.0新特性!
- 2024-09-10MySQL分库分表教程:入门级解决方案与实践
- 2024-09-10MySQL教程:初学者的入门指南
- 2024-09-10MySQL教程:从零开始入门的步骤与实践
- 2024-09-10MySQL慢查询教程:轻松掌握优化技巧
- 2024-09-10MySQL慢查询教程:快速提升数据库性能的入门指南
- 2024-08-27mysql ddl常用的方法和语句-icode9专业技术文章分享
- 2024-08-13MySQL入门:轻松掌握数据库基础操作与技巧
- 2024-08-12Seata和Mysql存储演示学习入门:初级开发者实战指南
- 2024-08-10从 MySQL 迁移到 TiDB:使用 SQL-Replay 工具进行真实线上流量回放测试 SOP