PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.database.mysql > column alias on mass
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
column alias on mass

Réponse
 
LinkBack Outils de la discussion
Vieux 02/05/2006, 14h40   #1
sks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut column alias on mass

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.


  Réponse avec citation
Vieux 02/05/2006, 17h05   #2
Bill Karwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: column alias on mass

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.
  Réponse avec citation
Vieux 03/05/2006, 17h08   #3
sks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: column alias on mass


"Bill Karwin" <bill@karwin.com> wrote in message
news:e3801202ia4@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.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h18.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18115 seconds with 11 queries