Re: [LA-discussions] mysql

[ Thread Index | Date Index | More linuxarverne.org/discussions Archives ]


Salut

On Sat, Nov 28, 2009 at 01:01:48PM +0100, Matthieu wrote:
> Tu utilise la clause WHERE pour joindre les 2 tables comme ceci :
> 
> SELECT u.pseudo, c.nom, c.prenom, c.mail, c.etc
> FROM jos_users u, jos_comprofiler c
> WHERE u.id = c.id;
> 
> Euh... J'ai toujours utilisé ceci :
> 
> SELECT u.pseudo, c.nom, c.prenom, c.mail, c.etc
> FROM jos_users AS u
> LEFT JOIN jos_comprofiler AS c ON c.id = u.id;
> 
> Quel est la différence ? Y'a t-il une méthode plus rapide ou meilleurs que
> l'autre ?

Le AS est facultatif.  C'est marqué dans la doc de MySQL ici:
http://dev.mysql.com/doc/refman/5.4/en/join.html

Mais aucune info sur la spécificité à MySQL ou non.... Bref, comme
d'hab, il faut chercher dans la doc de PostgreSQL pour faire du MySQL
(donc autant utiliser PostgreSQL?) pour avoir des infos sur le fait que
ça soit portable d'un SGBD à l'autre ou pas:
http://www.postgresql.org/docs/8.4/static/sql-select.html

« Omitting the AS Key Word
  ------------------------

In the SQL standard, the optional key word AS can be omitted before an
output column name whenever the new column name is a valid column name
(that is, not the same as any reserved keyword). PostgreSQL is slightly
more restrictive: AS is required if the new column name matches any
keyword at all, reserved or not. Recommended practice is to use AS or
double-quote output column names, to prevent any possible conflict
against future keyword additions.

In FROM items, both the standard and PostgreSQL allow AS to be omitted
before an alias that is an unreserved keyword. But this is impractical
for output column names, because of syntactic ambiguities. »


-- 
Romain Tartière <romain@xxxxxxxxxxxx>        http://romain.blogreen.org/
pgp: 8DAB A124 0DA4 7024 F82A  E748 D8E9 A33F FF56 FF43 (ID: 0xFF56FF43)
(plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)

Attachment: pgpXBngWoKRKn.pgp
Description: PGP signature



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/