In a join, how to prefix all column names with the table it came from

后端 未结 9 1779
你的背包
你的背包 2020-12-08 02:13

I\'m analysing a rather horrible legacy database/codebase, trying to reduce server load by combining queries into joins (including an email alert cron job that typically inv

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 03:04

    You could

    select ah.*, l.*, u.*, pi.* from ...
    

    then the columns will be returned ordered by table at least.

    For better distinction between every two sets of columns, you could also add "delimiter" columns like this:

    select ah.*, ':', l.*, ':', u.*, ':', pi.* from ...
    

    (Edited to remove explicit aliases as unnecessary, see comments.)

提交回复
热议问题