拥有以下代码:
SELECT a.*
, tb_media.filename
, tb_galleries.name
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name
FROM
我无法对colum名称(不是我的数据库设计)做什么,我如何区分结果中名为'name'的两个列?
答案 0 :(得分:4)
您应该为任何具有相同名称的列提供别名:
SELECT a.*
, tb_media.filename
, tb_galleries.name as Name1
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name as Differentname
FROM
答案 1 :(得分:3)
你应该使用别名 -
SELECT a.*
, tb_media.filename
, tb_galleries.name AS gallery_name
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name AS folder_name
FROM
关键字 AS 可能会被省略 - tb_galleries.name gallery_name
答案 2 :(得分:2)
使用AS
时,只需在查询中为其提供备用列名。
示例:
SELECT a.*
, tb_media.filename
, tb_galleries.name AS 'tb_g_name'
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name AS 'tb_f_name'
FROM
答案 3 :(得分:2)
SELECT a.*
, tb_media.filename
, tb_galleries.name AS name_1
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name AS name_2
答案 4 :(得分:1)
SELECT a.*
, tb_media.filename
, tb_galleries.name as Name1
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name as Name2
FROM
答案 5 :(得分:1)
您可以使用列别名来区分名称。
Have the following code:
SELECT a.*
, tb_media.filename
, tb_galleries.name as gallery_name ---(or whatever name u want)
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name as folder_name ---(or whatever name u want)
FROM
答案 6 :(得分:-1)
您可以使用AS关键字:
SELECT a.*
, tb_media.filename
, tb_galleries.name AS galleryName
, tb_media_iptc.description
, tb_media_iptc.title
, tb_media_iptc.headline
, tb_folders.name AS foldersName
FROM
这将更改列的显示名称...