问题描述
我是PHP和MYSQL数据库的新手.我正在尝试从我的两个表中显示表中的行.我想要来自称为Teacher_profile的表的所有行,并希望来自中心的名称列.我可以在phpmyadmin中运行查询,并且可以正常运行,但问题是两个表的名称都很常见,因此我无法在表中正确显示centername.因为那里Teacher_profile和center都有name列.我不能重命名它,因为它可以在我的android应用程序中使用.
I am new in PHP and MYSQL database. I am trying to display row in table from my two table. I want all row from table called teacher_profile and want name column from center. I am able to run query in phpmyadmin and its working fine but issue is both table have name is common so I am not able to properly display centername in my table. because there teacher_profile and center both have name column. I can not rename it because its live and used with my android application.
select *
from teacher_profile q
left outer join center a on a.id = q.centerId
ORDER BY q.id DESC
我的查询就是这样,让我知道是否有人可以帮助我解决问题,因此我可以从center获得name列作为center_name,以便将其与表行一起使用.非常感谢!
My Query is like this, Let me know if someone can help me out from the issue and so I can get name column from center as center_name in result so I can use it with my table row.Thanks a lot!
注意:我只想要中心表中的名称列.并希望获得类似centername的名称,因此查询结果中不会出现多个列名称.谢谢
Note : I want only name column from center table. and want get something like centername so there no multiple column name come in query result.Thanks
推荐答案
您可以使用完全限定的列名. q.name
是teacher_profile
中的name
列,而a.name
是center
表中的name
列.
You can use fully qualified column names. q.name
is the name
column from teacher_profile
and a.name
is the name
column from the center
table.
这篇关于左联接表和表中的回显-MySQLi查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!