我正在处理数据库连接,我想要执行以下操作:
Select tabel_one.id,
tabel_one.title,
tabel_one.content,
table_two.value as table_two.key
from tabel_one
Join table_two ON table_two.id = table_one.id ....
重要的部分是:
table_two.value as table_two.key
有什么办法可以实现这一点吗?
最佳答案
不,您不能定义引用表的别名。
一般来说,您应该简单地使用:
table_two.value as key
否则,如 OMG Ponies suggested in another answer ,您可以将别名括在反引号中:
table_two.value as `table_two.key`
关于SQL 选择 table1.column 作为 table1.column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2602967/