左联接表和表中的回声
我正在尝试从我的两个表中显示表中的行.我想要来自称为Teacher_profile的表的所有行,并希望来自中心的名称列.我可以在phpMyAdmin中运行查询,并且可以正常运行,但问题是两个表的名称都很常见,因此我无法在表中正确显示centername.因为那里Teacher_profile和center都有name列.我无法重命名它,因为它已经存在并且可以在我的Android应用程序中使用.
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 it's 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,以便可以在表行中使用它?
How can I get name column from center as center_name in result so I can use it with my table row?
注意:我只想要中心表中的名称列,并且想要获取类似centername的名称,因此查询结果中不会出现多个列名称.
Note: I want only name column from center table and want to get something like centername so there no multiple column name come in query result.
您可以使用完全限定的列名. 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.