cytech Posted May 16, 2008 Share Posted May 16, 2008 Hey All, Not sure if this is even possible but figured I would give it a try. Say I have 5 columns in my table, column1, column2 etc... I want to pull column1 using a specified name and then the rest of the columns as is. Example SELECT column1 AS example FROM tbl Perfect, I now have column1's data in example. So next I try this: SELECT column1 AS example, * FROM tbl The above will give me column1's data as "example" however, it also duplicates it as column1 by using * when it displays all of the other columns. Is there a way I can name column1 as example and then call the rest of the columns without having to type them all out and not duplicating that initial column? I hope I explained it properly Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted May 16, 2008 Share Posted May 16, 2008 try select columnA as 'example', * from `tbl` Quote Link to comment Share on other sites More sharing options...
cytech Posted May 16, 2008 Author Share Posted May 16, 2008 Interesting thought, but did not work. I get a mysql error - If I place the "*" before columnA it will work. I am running mysql version 4.1.22. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM Quote Link to comment Share on other sites More sharing options...
fenway Posted May 16, 2008 Share Posted May 16, 2008 Is there a way I can name column1 as example and then call the rest of the columns without having to type them all out and not duplicating that initial column? No, not with a mysql query alone. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.