Connecting Tech Pros Worldwide Forums | Help | Site Map

SQL Query Question - JOIN or not to JOIN

Mike Curry
Guest
 
Posts: n/a
#1: Jan 2 '06
I have 2 tables, I will add sample data to them to help me explain...

Table1
(Fields: A, B)
=====
1,One
2,Two
3,Three

Table2
(Fields: A,B)
=====
2,deux
9,neuf

I want to create a query that will only return data so long as the key
(Field A) is on both tables, if not, return nothing. How can I do
this? I am thnking about using a 'JOIN' but not sure how to implement
it...

i.e: 2 would return data- but 9 would not...

any help would be appreciated.


Stu
Guest
 
Posts: n/a
#2: Jan 2 '06

re: SQL Query Question - JOIN or not to JOIN


This can be solved using a standard inner JOIN:

SELECT t1.*, t2.*
FROM Table1 t1 JOIN Table2 t2 ON t1.ColumnA = t2.ColumnB

Since you're asking the question, it's obvious that you are probably
new to SQL. Newsgroup posters can be harsh teachers; I'd suggest that
you pick up a couple of books on basic SQL. I like Ben Forte's 10
Minute Guide to SQL as a basic primer.

HTH,
Stu

--CELKO--
Guest
 
Posts: n/a
#3: Jan 2 '06

re: SQL Query Question - JOIN or not to JOIN


>> Newsgroup posters can be harsh teachers; I'd suggest that
you pick up a couple of books on basic SQL. <<

Ahh, come on, Stu, let me eat the newbie!! Let me eat the newbie!!

But let's start him with a book on RDBMS theory and some data basics.
<< insert plug for my stuff here >>

Mike Curry
Guest
 
Posts: n/a
#4: Jan 3 '06

re: SQL Query Question - JOIN or not to JOIN


Hmm... why are you guys putting me in this big black pot? Whoa... why
are you throwing carrots in here with me? This water is nice and
warm... is that chicken base your dropping in here?

Sounds like I am about to be lunch!!

I bought a couple books at amazon as well, they have good deals, I
managed to pick a couple of the books up fairly cheap as they were
previously used.

Regards, and thanks for the help,
Bugs Bunny (lol)

Closed Thread