is there a way to have a mysql select statement return fully qualified column names like "table.field" without using AS for every single field?
like so:
SELECT *
FROM table1
LEFT JOIN table2 on table1.f_ID = table2.ID
and the result would be: "table1.ID", "table1.name", "table2.ID", "table2.name", ...
If you are using PHP you can use PDO to get this result.
$PDO->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, true);
See SQL Select * from multiple tables for more information.
Not really. You could write some dynamic SQL to accomplish this, but it wouldn't be simple. If you really want the dynamic SQL, let me know and I could try to whip something up.
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