August 23, 2005 at 8:31 am
HI,
I wish to join two tables and produce a reult set that has all of the columns of each table. E.g.
table1 has columns A,B,C,D and table2 has columns A, E, F, G
How do I write the syntax that pulls all of the columns from each of the two tables?
thanks,
Paul
August 23, 2005 at 8:52 am
i'm not sure if this is just a simple join question or if there's some underlying complexity that i'm missing altogether...paul...you can set me straight...
select t1.A, t1.B, t1.C, t1.D, t2.E, t2.F, t2.G from table1 t1
inner join
table2 t2
on t1.A = t2.A
edited....
**ASCII stupid question, get a stupid ANSI !!!**
August 24, 2005 at 2:37 am
No complexity here ! I am just beginning sql queries and wanted to be sure of the correct syntax so that I can progress in the correct manner.
Just a join of two tables.
I simply want to pull all the info from all the columns in table1 and table2 so that I can have one big result setwith the full contents of both tables.
Question: If I am selecting everything from one table and everything from another, why can't I do "select * from table1 then a join - select * from table2 - bad syntax or simply won't work. ?
Also, Forgive my beginnerness, but why do you have "on t1A = T2A"
Is this the column(s) on which the join takes place ?
thanks Again.
Paul
thanks
August 24, 2005 at 6:57 am
This will answer most of your basic questions :
August 24, 2005 at 7:31 am
remi's sent you a great link...
just want to answer your questions though -
you could do a select * - except you will get your column A repeated twice in this case since both your tables have this column and you don't want to look at more information than you need to/must!
I gave your table1 and table2 what is called an alias - this is for convenience only - to make the typing easier splly. when there are long table names and many joins involved - eg: if you had a table called tblThisIsMyVeryFirstTable - you give it an alias of tbl1 so you don't have to type this every single time and you also increase readability.
lastly - the join always takes place on the columns that are common to the tables - so yes, if your table1 and table2 had column A (as you indicated) - then, that's where the join would take place.
**ASCII stupid question, get a stupid ANSI !!!**
August 24, 2005 at 2:38 pm
Of course this would assume that you would only want to see records where Value A was in both tables. If You wish to see all of the records from Table1, then an outer join would apply.
August 24, 2005 at 2:43 pm
Stay BASIC please .
August 24, 2005 at 2:46 pm
Gomen Asai matemas! (Most humbly sorry! Nipponese)
August 24, 2005 at 2:47 pm
NP... Don't wanna get into that when he doesn't know how to select .
August 24, 2005 at 3:06 pm
nain gimon - badly written nipponese for - exactly the same reason as remi why i didn't go into this as well...
**ASCII stupid question, get a stupid ANSI !!!**
August 24, 2005 at 3:12 pm
Well I'll leave you all with that quote .
August 24, 2005 at 3:18 pm
just don't quote me on it remi, is all...sayonara!
**ASCII stupid question, get a stupid ANSI !!!**
August 24, 2005 at 3:19 pm
Ok Ok.
Gomen-A-Sai mattemasu
(I'm Sorry)
So it's been 34 years since I was in Japan!
August 24, 2005 at 3:28 pm
you know SLFine...things are difficult enough when we do this in English...why don't we just leave other languages out till we've got at least one mastered ?!?!
**ASCII stupid question, get a stupid ANSI !!!**
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply