Select only some columns from a table on a LEFT JOIN

前端 未结 3 418
野性不改
野性不改 2021-02-05 06:20

Is it possible to select only some columns from a table on a LEFT JOIN?

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-05 07:02

    Of course. Just list the columns you want to select as you would in any query:

    SELECT table1.column1, table1.column2, table2.column3
    FROM table1
    LEFT JOIN table2 ON (...)
    

    Note that I've included the table1. or table2. prefix on all columns to be sure there aren't any ambiguities where fields with the same name exist in both tables.

提交回复
热议问题