Insert Select Sql From Two Tables
I have two tables one table tbl_OrderLine with order ID and one tbl_Student with Student ID. I want to select the OrderLineID from tbl_OrderLine and The StudentID From tbl_Student
Solution 1:
You want to define your select as a join instead of two separate SQLs. I am not really sure how MS works, but something like this should do the trick:
INSERTINTO tbl_StudentPurchaseFromUnibooks (OrderLineID, StudentID )
SELECT tbl_OrderLineID.OrderLineID, tbl_Student.StudentID
from tbl_OrderLineId
leftjoin tbl_Student on ???
WHERE tbl_Student.LoggedIn ="Yes";
I am not sure that your table should really be named tbl_OrderLineID and you would need to know your join condition.
Post a Comment for "Insert Select Sql From Two Tables"