Is it possible to select only some columns from a table on a LEFT JOIN?
Just list the columns you want to select as you would in any query: SELECT table1. column1, table1. column2, table2.
To select columns, choose one of the following options: Type SELECT , followed by the names of the columns in the order that you want them to appear on the report. Use commas to separate the column names.
Either specify * , and get all columns, or specify each one you want, from col5 to col1000. (1000 columns indicates a poorly designed database.) If you could tag which particular DBMS are you using, you might find a solution involving dynamic SQL with a metadata query that builds your SQL for you.
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.
Add a *
to just that table in your select statement, separate from other columns with a comma:
SELECT table1.*, table2.col2, table2.col3 FROM table1 LEFT JOIN table2 ON...
Source: https://stackoverflow.com/a/3492919/3417198
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With