column alias on mass

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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.price

Obviously I can do this manually as such

select,, p.price from products p ....

But that would take a lot of big queries as some of my tables have 50

Re: column alias on mass

sks wrote:
Quoted text here. Click to load it

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 as ``, as ``, 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.

Bill K.

Re: column alias on mass

Quoted text here. Click to load it

Ok thanks for replying.

Site Timeline