Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I want to insert data in my tblOrder with surent paramaterI get the controls out of al my paramaters.But ons of my controls contains the text of a Title of a book.In my table i want to to insert this book_id. The title of this book is in an other table tblBoek. But i want to enter al my data in tblOrders.TblOrders TbloekID IDNaam TitelBoek_ID Auteurthe Boek_ID is i an relationship with the ID form tblBoekSQL:"INSERT INTO tblOrders (ID, NAME, ADDRESS, DATE, BOOK_ID,) " + "WHERE "VALUES (@Id, @Name, @Address, @Date, )"; //for my parameters these values are in controls "FROM tblOrders INNER JOIN tblBooks ON tblOrders.BOOK_ID = tblBooks.BOOK_ID";SOMETHING WITH WHEREbut the books ID doesnt work without it it willthx!!
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts
Posted - 2010-05-23 : 07:12:05
Insert statements have two forms. Insert ... Values, where you specify all the values that you want to insert eg
Insert into SomeTable (col1, col2)Values ('abc',2)
Insert .. select where you're pulling values from another table to insert. eg
Insert into SomeTable (col1, col2)SELECT SomeCoumn, AnotherColumns FROM AnotherTable Where someCondition