Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
duanecwilson
Constraint Violating Yak Guru
273 Posts |
Posted - 2009-08-06 : 18:30:24
|
I am going in circles with this query. I tried to do it without the query graphical editor and now I am trying it with. And I still can't figure it out. O_WORKSTATION has only 561 rows in it. All I want is to go over to the O_OPERATOR table and get the Operator_Name and later one or two other fields from the other tables. As it stands now, I get more than 250,000 rows before stopping it. Can someone please help me figure this out?SELECT O_OPERATOR.OPERATOR_NAME AS [Last User], O_WORKSTATION.STATION_NAME AS Station ,O_WORKSTATION.LAST_SYNCHRONIZED AS [Most Recent Synchronization Date] ,SYS_SYNCH_LOG.SYNCH_TYPE AS TypeFROM O_WORKSTATION INNER JOIN SYS_SYNCH_LOG ON O_WORKSTATION.STATION_ID = SYS_SYNCH_LOG.STATION_ID INNER JOIN O_OPERATOR ON SYS_SYNCH_LOG.OPERATOR_ID = O_OPERATOR.OPERATOR_ID Thank you for any help.Duane |
|
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2009-08-06 : 19:46:04
|
| Without seeing your tables I can only be guessing but...It looks like the sync_log table could contain several entries for any particular workstation. Therefore, when you join the tables you get more than the number of workstations in your results. If more than one operator is involved in the workstation syncing, the number gets greater still.Are you trying to get a single operator associated with the workstation and, if so, which operator if more than one is involved?Are you trying to get a single synch_log associated with the workstation and, if so, which one? The last one?If there is a field in the sync_log table that cooresponds to the workstation.last_synchronized field then perhaps joining the tables on more than one column is needed.select o_operator.operator_name as [last user], o_workstation.station_name as station, o_workstation.last_synchronized as [most recent synchronization date], sys_synch_log.synch_type as typefrom o_workstation inner join sys_synch_log on o_workstation.station_id = sys_synch_log.station_id and o_workstation.last_synchronized = sys_synch_log.???inner join o_operator on sys_synch_log.operator_id = o_operator.operator_id=======================================Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727) |
 |
|
|
|
|
|
|
|