MySql SELECT AS - Append all field names

前端 未结 4 1676
傲寒
傲寒 2021-01-17 11:32

I\'d like to do something like this:

SELECT table.id AS prefix_id, table.name AS prefix_name

... and have the prefix added dynamically to a

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 11:52

    When you reference the results, you can reference each column by the tablename.column . Therefore you have a default prefix that is appended to each column name.

    SELECT table.id,table.name,other.name FROM table,other Where other.name = table.name;
    

提交回复
热议问题