小编典典

来自两个表的具有相同名称的mysql额外列

sql

表1包含列:entry_id user_id …表2包含列:entry_id user_id …

user_id条目并不总是相同的,因此我想将它们都提取出来,以便以后可以在脚本中对它们进行比较

SELECT * FROM 
table1 as t1
INNER JOIN table2 as t2 on t1.entry_id=t2.entry_id
WHERE t1.user_id='%s'

我想提取t1.user_id和t2.user_id …问题是结果数组只有user_id

谢谢你


阅读 195

收藏
2021-04-14

共1个答案

小编典典

使用AS关键字:

SELECT
  t1.user_id as t1_user_id
  ,t2.user_id as t2_user_id
FROM table1 as t1
INNER JOIN table2 as t2
  ON t1.entry_id=t2.entry_id
WHERE t1.user_id='%s'
2021-04-14