左联接表和表中的回声 [英] Left Join Table and Echo in Table

查看:72
本文介绍了左联接表和表中的回声的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的两个表中显示表中的行.我想要来自称为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.nameteacher_profile中的name列,而a.namecenter表中的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.

这篇关于左联接表和表中的回声的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆