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
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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.