Jump to content

Interesting Select Statement


cytech

Recommended Posts

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

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

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.