Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Statment

Posted on 2011-02-24
5
Medium Priority
?
436 Views
Last Modified: 2012-05-11
I would to grab data from 2 different tables with one sql statment , how can I do that .
one of my table has info about a job alog with a tech id and the other table has the name of this tech id , I would like to display the job info and also the full name of this tech id.
here are my main SQL statment:
strsql = " select STATIONID, STATUS, TECHID from SVC06103 where WORKORDNUM = '" & StrWORTVNum.Value & "'"

my other table SVC00100 has the "TECHID" , "NAME", and "OFFID" fields. I would like to pull the NAME and OFFID from this table
Can someone help me with the correct statment
Thanks
David
0
Comment
Question by:taverny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 41

Accepted Solution

by:
Sharath earned 800 total points
ID: 34976280
strsql = " select t1.STATIONID, t1.STATUS, t1.TECHID,t2.NAME,t2.OFFID from SVC06103  t1 JOIN SVC00100  t2 ON t1.TECHID = t2.TECHID where t1.WORKORDNUM = '" & StrWORTVNum.Value & "'"
0
 
LVL 17

Assisted Solution

by:dbaSQL
dbaSQL earned 1200 total points
ID: 34976300

select s.STATIONID, s.[STATUS], s.TECHID,ss.[name],ss.offid
from SVC06103 s JOIN SVC00100 ss
 on s.techid = ss.techid
where s.WORKORDNUM = the given value
0
 

Author Comment

by:taverny
ID: 34976512
Thanks the code works and you both got it right . I know it's not part of my question but if I wanted to join it whith a 3rd table on StationID , how would I do that on the same SQL.
If I understand how to use the join would it be something like that?:

strsql = " select t1.STATIONID, t1.[STATUS], t1.TECHID, t2.[NAME], t2.OFFID, t3.[Description] from SVC06103  t1 JOIN SVC00100  t2 ON t1.TECHID = t2.TECHID JOIN SVC0615 t3 ONt1.STATIONID = t3.STATIONID where t1.WORKORDNUM = '" & StrWORTVNum.Value & "'"

Thanks in advance
0
 
LVL 17

Assisted Solution

by:dbaSQL
dbaSQL earned 1200 total points
ID: 34976524
Yes, that is correct.  If stationID is the equal value in both tables, that is correct.
0
 

Author Comment

by:taverny
ID: 34976641
Thank you it works
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question