|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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) |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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) |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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/ |
|
![]() |
| Outils de la discussion | |
|
|