JRLRANDOM TV JRLRANDOM TV - 3 months ago 7
C# Question

Insert and then get value from a select

Help I am new to SQL query I have 3 tables the

tbl_STUDENT
,
tbl_SESSION
and
tbl_STUDENTSESSION
I want to pass the
total_session
value from
tbl_SESSION
to
tbl_STUDENTSESSION
table.
im getting incorrect syntax near 'select' Here is my query:


INSERT INTO tbl_STUDENTSESSION(Student_ID,Session_ID,Total_Session) values(6000,4000,Select Total_Session from tbl_SESSION where Session_ID=4000);

Answer

Try to use

INSERT INTO tbl_STUDENTSESSION(Student_ID,Session_ID,Total_Session)  Select 6000,4000, Total_Session from tbl_SESSION where Session_ID=4000
Comments