473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

column alias on mass

sks
Hi all,

Is possible to retrieve all columns and alias them all at once. Eg, normally
you would write

select * from products which would return

id | name | price
-----------------------
1 | Test | 14.00

but I want to be able to say

select p.* from products p, so that it returns the columns as such

p.id | p.name | p.price

Obviously I can do this manually as such

select p.id, p.name, p.price from products p ....

But that would take a lot of big queries as some of my tables have 50
columns.
May 2 '06 #1
2 3457
sks wrote:
but I want to be able to say

select p.* from products p, so that it returns the columns as such

p.id | p.name | p.price

Obviously I can do this manually as such

select p.id, p.name, p.price from products p ....


Actually, that would return

id | name | price

The column labels don't implicitly include the table alias dot notation.
You'd have to do a query like this:

select p.id as `p.id`, p.name as `p.name`, p.price as `p.price` from
products p ....

It's good to get in the habit of using the backquotes, because then you
can use special characters or even whitespace in your column labels.

There is no syntax to declare the column labels automatically. You have
to specify all of them individually.

Regards,
Bill K.
May 2 '06 #2
sks

"Bill Karwin" <bi**@karwin.com> wrote in message
news:e3*********@enews4.newsguy.com...
sks wrote:
but I want to be able to say

select p.* from products p, so that it returns the columns as such

p.id | p.name | p.price

Obviously I can do this manually as such

select p.id, p.name, p.price from products p ....


Actually, that would return

id | name | price

The column labels don't implicitly include the table alias dot notation.
You'd have to do a query like this:

select p.id as `p.id`, p.name as `p.name`, p.price as `p.price` from
products p ....

It's good to get in the habit of using the backquotes, because then you
can use special characters or even whitespace in your column labels.

There is no syntax to declare the column labels automatically. You have
to specify all of them individually.


Ok thanks for replying.
May 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gord | last post by:
Hello, Anybody know how to detect when a user drags between columns in a MSHFlexGrid when resizing column width? (Short of setting up a timer event that continuously monitors column width.)...
3
by: Andrew | last post by:
With command-line interface ( 3.23.37, UNIX Socket ) all is well with column aliasing. However, column aliases disappear in Excel, over ODBC, when there are multiple (joined) tables in the query. ...
2
by: muzamil | last post by:
Hi Your help for the following query will be highly apprecaited. I've wasted alot of time on it. Data definition is at the bottom. Thanks -----------------------------------
2
by: Stefan Leitich | last post by:
i have the following function: declare prim_col_name Alias for $1; prim_col_val Alias for $2; my_column Alias for $3; link_table Alias for $4; link_col Alias for $5; data_table alias for $6;...
10
by: GML | last post by:
I have a bound datagrid in C# based on an an SQL query. The results are displayed in a Sharepoint 2003 Webpart. I would like to add a new column based on the results of two columns in the...
1
by: deepak | last post by:
Hi There, i have a requiremet ,where in i have a view which has some alias.so at runtime using an application i will get the info about the view using SP_HELP stored proc,but this only gives me...
1
by: Plamen Ratchev | last post by:
You cannot use a column alias in the definition of another column. The solution is as you found to repeat the expression. Alternative solution is to define the first column in one CTE (or derived...
12
by: sheppardpg | last post by:
I have a a query with a column that needs to have a data type of Memo, which I am able to achive with this function; Public Function MEMO() MEMO (COMMENTS) End Function I want to define the...
1
by: Slapo | last post by:
Hello everyone, I could use some help with this function I've created (see below) that runs flawlessly on PostgreSQL 8.3.6 on my development machine but ends with an error on the production server...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.