By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,278 Members | 1,106 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,278 IT Pros & Developers. It's quick & easy.

Join statement

P: n/a
Hi.........

Its been awhile since I've touched SQL statements, so I need some help
with writing a JOIN statement to query 3 tables.

The dB has 3 tables with values
Applications
-Application_code(Primary key)
-Application_name

Applications_Installed
-Computer_name(Pri key)
-Application_code(Foreign key/sec key)

Workstation_info
-Computer_name(Pri key)
-Serial_number

What I want to do is query the tables for a particular Application code
and name from Applications, so that it returns the values of computer
names with the matching values from Applications_installed and
Workstation_info.

So I need to do a

Select * from applications where applications.application_code='XXX'
join (this is the part I'm stuck how do I tell it to match the
applications.application_code =
applications_installed.application_code) then match the computer names
from Applications_installed.computer_name with that of
workstation_info.computer_name

Not sure if I'm explaining this properly....

Can anyone help.......

Oct 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Stu
Hey Zeno,

I think what you're looking for is:

SELECT columnlist
FROM Applications a JOIN Applications_Installed ai ON
a.Application_Code = ai.Application_Code
JOIN Workstation_Info wi ON ai.Computer_Name = wi.Computer_name
WHERE a.application_code = 'XXX'

May I also suggest that you pick up a reference guid on basic SQL;
newsgroups can be harsh teachers :) Years ago, I found Ben Forta's 10
Minute Guide very good at covering the basic concepts:

http://www.amazon.com/exec/obidos/tg...24660?v=glance

HTH,
Stu

Oct 12 '05 #2

P: n/a
Thanks Stu.........

I'll give it a try and let you know how things go............
Cheers

Oct 12 '05 #3

P: n/a
Thanks Stu.........

I'll give it a try and let you know how things go............
Cheers

Oct 12 '05 #4

P: n/a
use ACCESS DATA PROJECTS they allow you to drag and drop fields around
instead of getting frustrating writing queries.

TSQL is too hard to just dive into -- use ADP as a crutch to help you
to start getting things done and stop worrying about syntax.

Oct 12 '05 #5

P: n/a
(aa*********@gmail.com) writes:
use ACCESS DATA PROJECTS they allow you to drag and drop fields around
instead of getting frustrating writing queries.

TSQL is too hard to just dive into -- use ADP as a crutch to help you
to start getting things done and stop worrying about syntax.


I would say that this is a poor advice in the long run. Maybe if you
only compose a query once or twice a year maybe. But else learning
SQL syntax pays off.

And using Access may not necessarily be helpful, since there are
significant differences between the SQL in Access and Transact-SQL.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Oct 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.