How do you avoid column name conflicts?

前端 未结 8 1134
挽巷
挽巷 2021-01-05 12:35

I was recently assigned a task of creating an auction system. During my work, I met numerous occasions where my SQL queries that contained joins failed to execute due to amb

相关标签:
8条回答
  • 2021-01-05 13:22

    You can also define the table column beside the table name:

    SELECT P.*,T.name AS type FROM <TABLE-A> AS P LEFT JOIN <TABLE-B> AS T ON P.id=T.id
    
    0 讨论(0)
  • 2021-01-05 13:24

    May be you can try using aliases on the table names ?

    select * from table1 as T1
    join table2 as t2 on (t1.key=t2.foreignkey)
    
    0 讨论(0)
提交回复
热议问题