Alex Rivera | Logout

When Selecting everything from MySQL can I rename specific fields and still select everything else as is with the *

Asked 2011-05-19T23:50:29.630
10

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.

Edit
Report

1 Answer

0

Ryan, you can do what you want to. The only catch is, the results will include both youth_id and id with the same values for each. If you want only youth_id & not id, then you'll have to list all the columns you want instead of using '*'. Incidentally, if you have phpmyadmin handy, you could just enter the sql and see the result immediately.

answered 2011-05-19T23:56:55.790

Your Answer