Hey again guys. So, I'm trying to find out how to select every field across multiple tables in a mysql database and output the resulting table to a .csv file for Excel. I've found the infamous stackoverflow question dealing with .csv ouput and have all the code there. So, I guess what I'm asking is:
Is there a way to do a mysql query that looks something like this?
SELECT * prof.id AS youth_id FROM time time, profiles prof, WHERE foo='bar'
and have it select everything from both (or like 4) tables but select the id as youth_id, or do I have to specify EVERY value that I want if I need to select certain values as another name?
I would like to not have to specify every field as I have like 50+ to output.
I've tried to search but can't really find what I need. I guess if you could point me in the right direction that would be great.
You don't have to specify every field. Instead you can do the following:
SELECT *, prof.id AS youth_id FROM time time, profiles prof
However the above will return all columns from the two tables plus the column you renamed. So if the original two tables have 4 columns total and you rename one, you will get 5 columns in the result set.
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