PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > select *
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
select *

Réponse
 
LinkBack Outils de la discussion
Vieux 01/04/2008, 19h15   #1
Hiep Nguyen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut select *

hi all,

how do i select all fields in tbl1,tbl2, and only fld1,fld2 in tbl3?

is this possible???

select *,*,tbl3.fld1,tbl3.fld2 from tbl1,tbl2,tbl3;

the reason for this is b/c there are hundred of fields in tbl1 & tbl2 that
i don't want to type them all.

thanks,
t. hiep


  Réponse avec citation
Vieux 01/04/2008, 19h20   #2
Rob Wultsch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select *

On Tue, Apr 1, 2008 at 11:15 AM, Hiep Nguyen <hiep@ee.ucr.edu> wrote:

> how do i select all fields in tbl1,tbl2, and only fld1,fld2 in tbl3?
>

select tbl2.*,
tbl1.*,
tbl3.fld1,
tbl3.fld2
from tbl1,tbl2,tbl3;
Please also consider using explicit JOINs.

--
Rob Wultsch
wultsch@gmail.com
wultsch (aim)

  Réponse avec citation
Vieux 01/04/2008, 19h54   #3
Tim McDaniel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select *

On Tue, 1 Apr 2008, Rob Wultsch <wultsch@gmail.com> wrote:
> On Tue, Apr 1, 2008 at 11:15 AM, Hiep Nguyen <hiep@ee.ucr.edu> wrote:
>
>> how do i select all fields in tbl1,tbl2, and only fld1,fld2 in tbl3?
>>

> select tbl2.*,
> tbl1.*,
> tbl3.fld1,
> tbl3.fld2
> from tbl1,tbl2,tbl3;


Hiep, will you be supplying a WHERE clause to keep from getting all
possible combinations of rows from tbl1, tbl2, and tbl3? (Or am I
misunderstanding something?)

> Please also consider using explicit JOINs.


Another way to do the same thing with different syntax, right?

--
Tim McDaniel, tmcd@panix.com
  Réponse avec citation
Vieux 01/04/2008, 20h25   #4
Hiep Nguyen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select *

On Tue, 1 Apr 2008, Tim McDaniel wrote:

> On Tue, 1 Apr 2008, Rob Wultsch <wultsch@gmail.com> wrote:
>> On Tue, Apr 1, 2008 at 11:15 AM, Hiep Nguyen <hiep@ee.ucr.edu> wrote:
>>
>>> how do i select all fields in tbl1,tbl2, and only fld1,fld2 in tbl3?
>>>

>> select tbl2.*,
>> tbl1.*,
>> tbl3.fld1,
>> tbl3.fld2
>> from tbl1,tbl2,tbl3;

>
> Hiep, will you be supplying a WHERE clause to keep from getting all
> possible combinations of rows from tbl1, tbl2, and tbl3? (Or am I
> misunderstanding something?)
>
>> Please also consider using explicit JOINs.

>
> Another way to do the same thing with different syntax, right?
>
> --
> Tim McDaniel, tmcd@panix.com
>


thanks. the WHERE is very long, so i skipped here. i'll try JOIN, newbie
on JOIN.

  Réponse avec citation
Vieux 01/04/2008, 20h34   #5
Rob Wultsch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select *

On Tue, Apr 1, 2008 at 11:54 AM, Tim McDaniel <tmcd@panix.com> wrote:

> > Please also consider using explicit JOINs.

> Another way to do the same thing with different syntax, right?
>


Generally speaking it is another way to do the same thing, however it is
much easer to read complicated queries that use explicit JOIN syntax.

Recently (5 series) the precedence of the comma and JOIN was made
different, so some queries that used both broke.

According to the manual multi-table UPDATE and DELETE queries can use
explicit join syntax, but I have had issues with that in the past, and only
achieved success using implicit (comma) joins. YMMV.

--
Rob Wultsch
wultsch@gmail.com
wultsch (aim)

  Réponse avec citation
Vieux 07/04/2008, 02h00   #6
Baron Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select *

On Tue, Apr 1, 2008 at 3:34 PM, Rob Wultsch <wultsch@gmail.com> wrote:
> According to the manual multi-table UPDATE and DELETE queries can use
> explicit join syntax, but I have had issues with that in the past, and only
> achieved success using implicit (comma) joins. YMMV.


Hmm. Are your issues solved by the suggestions in this post?
http://www.xaprb.com/blog/2006/08/07...ases-in-mysql/

Baron

--

Baron Schwartz, Senior Consultant, Percona Inc.
Tel: +1 888 401 3401 ext 507
24/7 Emergency Line +1 888 401 3401 ext 911
Our Services: http://www.percona.com/services.html
Our Blog: http://www.mysqlperformanceblog.com/
  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 09h58.


É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,11962 seconds with 14 queries