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
 SQL Server Development (2000)
 Inserting Data

Author  Topic 

macca18
Starting Member

7 Posts

Posted - 2006-05-03 : 06:15:27
Hi,

I have a table, Alert, that is made up of three entries as shown belowwhich
come from other tables.

Table Alert
-------------
RoomID - (int)PK. This a foreign key from room table
EventTypeID - (int)PK. This is foreighn key from EventType table
RegionID - (int)PK. THis is foreign key from Region table


Table EventType
-------------------
EventTypeID - (int) PK
EventDescription - (nVarChar)


Table Room
--------------
RoomID -(int) PK
Dimensions - (nchar)
.
.

Table Region
---------------
RegionID - (int) PK
RegionDescription -(nvarchar)


I am relatively new to database programming and i am having trouble building
the query to input an entry into the Alert table. I am having trouble because
the entries are ID values from other tables.

What information do I need to be able to add entries to the Alert table?
How do I construct the query?

Thanks In advance
Macca

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2006-05-03 : 06:28:55
Region, Room and Event are linked togather using the Alert Table, so you require the information about how they are linked togather.. and their ids.. and then insert them in the Alter Table. you must be linking them from the front end application so pull the id of each primary table and insert them in the Alert table.

Now for pulling out the records from the Alert table, you need to learn the concepts of Join. Take a look in book online for Joins.

Its always better, when you post over here, post same sample data so that it gets easy for understanding..


If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-03 : 06:34:08
you have to insert into Region, EventType & Room table first before inserting into Alert table

Example :

insert into Region(RegionID, RegionDescription)
values (1, 'aaa')

insert into EventType (EventTypeID, EventDescription)
values (10, 'bbb')

insert into Room (RoomID, Dimentions)
values (100, 'ccc')

insert into Alert(RoomID, EventTypeID, RegionID)
values (100, 10, 1)



KH

Go to Top of Page
   

- Advertisement -