4 个表内连接 SQL 语句
我有这个数据库结构...
(它是西班牙语,希望并不重要),我做了这个使用内部联接查询,但我没有得到任何结果,所以我想我做错了什么...这是我的查询...
SELECT TBoleta.NroSerie+'-'+TBoleta.NroBoleta Boleta, TBoleta.Fecha,
TAlumno.APaterno+' '+TAlumno.AMaterno+' '+TAlumno.Nombres as Apellidos_y_Nombres,
TGrupoModulo.Modulo + ' ' + TGrupoModulo.Seccion + ' ' + TGrupoModulo.Turno,
TBoleta.Monto
FROM TMatricula
inner join TAlumno on TMatricula.CodAlumno = TAlumno.CodAlumno
inner join TBoleta on TBoleta.NroMatricula = TMatricula.NroMatricula
inner join TGrupoModulo on TGrupoModulo.CodGrupoModulo = TMatricula.CodGrupoModulo
请...我将不胜感激任何帮助。谢谢!
I have this database structure...
(It´s on spanish, hope doesn´t matter) and I made this query using inner join but I don´t get any result so I guess I did something wrong... This is my query...
SELECT TBoleta.NroSerie+'-'+TBoleta.NroBoleta Boleta, TBoleta.Fecha,
TAlumno.APaterno+' '+TAlumno.AMaterno+' '+TAlumno.Nombres as Apellidos_y_Nombres,
TGrupoModulo.Modulo + ' ' + TGrupoModulo.Seccion + ' ' + TGrupoModulo.Turno,
TBoleta.Monto
FROM TMatricula
inner join TAlumno on TMatricula.CodAlumno = TAlumno.CodAlumno
inner join TBoleta on TBoleta.NroMatricula = TMatricula.NroMatricula
inner join TGrupoModulo on TGrupoModulo.CodGrupoModulo = TMatricula.CodGrupoModulo
Please... I will appreciate any help. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于初学者来说,这个属性并不存在; TBoleta.CodAlumno
编辑:现在您的查询似乎可以正常编译,请记住,内部联接需要每个联接中的数据具有匹配的值。如果其中一个连接不存在,您将得不到任何数据。分析您的数据以找出答案。您也可以首先执行左外连接,然后逐步移动到内连接。
For starters, this attribute doesn't exist; TBoleta.CodAlumno
Edit: Now that your query appears to be compiling fine, remember that inner joins necessitate data from each join to have matching values. If one of the joins don't, you get no data back. Analyze your data to figure this out. You could also do left outer joins at first, then move to inner joins step by step.
这只是一个粗略的猜测,但这行:
似乎不正确,因为 TBoleta 没有名为 CodAlumno 的列。您应该检查运行此查询时是否遇到任何错误。
This is just a cursory guess, but this line:
appears to be incorrect, because TBoleta doesn't have a column named CodAlumno. You should check to see if you're getting any errors whilst running this query.
如果任何字段列为空,则不显示结果。
此外,如果您想显示
empty
或null
值,您可以在查询中使用LEFT JOIN
If any field column is empty, then result is not displayed.
further if you want to display with
empty
ornull
values you can useLEFT JOIN
in your query