Inserting rows into a query

D

DJoe

You cannot insert into two tables at teh same time.

Here is the way you would do it assuming there is a one-to-
many
relationship between the VisiterInfo table and the [User
Log] table
and the fields listed are correct for the given tables.


INSERT INTO
(
[Visiter ID],
[Visiter Name],
[Visit Number],
)
VALUES(@VisID,@VisName, @VisNum

INSERT INTO [User Log]
(
[Visiter ID],
[Referer],
[IP],
[Date],
[Time],
[Entry Page]
)
VALUES(@VisID, @Ref, @IP, @Date, @Time, @EntryPage)
-----Original Message-----
Im an ASP.Net programmer and my SQL skills arnt that great but I need to use
some for data manipulation in my ASP.net applications.

I have the query "SELECT * FROM [User Log] RIGHT JOIN VisiterInfo ON [User
Log].[Visiter ID]=VisiterInfo.[Visiter ID]" which I use to select data from
two tables to display on screen. I use an Access file with an OleDb
connection.

I need to be able to insert rows into this query so that both tables are
updated but I cant figure it out I have try tried the sql below plus many
other alterations of it but cant get it to work. Does anyone have any
Ideas?

"INSERT INTO SELECT * FROM [User Log] RIGHT JOIN VisiterInfo ON [User
Log].[Visiter ID]=VisiterInfo.[Visiter ID]
([VisiterInfo.Visiter ID], [User
Log.Visiter ID], [Visiter Name], [Visit Number], [Referer], [IP], [Date],
[Time], [Entry Page]) VALUES (@VisID, @UVisID, @VisName, @VisNum, @Ref, @IP,
@Date, @Time, @EntryPage)"


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top