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 Link to comment https://forums.phpfreaks.com/topic/105929-interesting-select-statement/ Share on other sites More sharing options...
cooldude832 Posted May 16, 2008 Share Posted May 16, 2008 try select columnA as 'example', * from `tbl` Link to comment https://forums.phpfreaks.com/topic/105929-interesting-select-statement/#findComment-542864 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 Link to comment https://forums.phpfreaks.com/topic/105929-interesting-select-statement/#findComment-542872 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. Link to comment https://forums.phpfreaks.com/topic/105929-interesting-select-statement/#findComment-543025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.