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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Newbie: SELECT, JOIN etc

Author  Topic 

trenktaz
Starting Member

1 Post

Posted - 2005-06-28 : 08:04:56
Hello everyone,

I'm really poor in SQL language. So i need a SELECT for resolving my problem.

I have such tables (MSDE)
-----------------------------
Table COMPUTERS

compid | compname

with records
1 | computer1
2 | computer2
3 | computer3
-----------------------------

Table EVENTS

eventid | eventtype | timestamp | compid

with records
1 | 2 | 1119939932 | 1
2 | 1 | 1119939933 | 2
3 | 2 | 1119939934 | 3
-----------------------------

And Table EVENTSDESCRIPTION

eventtype | eventdescription

with records
1 | Node is Down
2 | Node is UP
--------------------------------

Now QUESTION
I need to write such SQL SELECT for..
Take eventtype, timestamp, compid records for last hour (for example... how to work with timestamp i know :) ) from table EVENTS, after that i need get computer names from COMPUTERS with previously obtained compid and eventdescription from EVENTSDESCRIPTION.

Let's supose that i have only one record for last hour eventid -> 3
My result must be "some_timestamp, computer3 Node is UP" or smth like that :-)

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-06-28 : 09:27:24
Try this
Select E.eventtype , E.timestamp ,E.compid, C.compname,ED.eventDescrition
from Events E inner join Computers C inner join EVENTSDESCRIPTION ED
on ED.eventtype=E.eventtype and E.compid=C.compid where E.eventId=3


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -