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
 General SQL Server Forums
 New to SQL Server Programming
 sql statement problem

Author  Topic 

fundum19
Starting Member

1 Post

Posted - 2010-05-23 : 04:50:48
I want to insert data in my tblOrder

with surent paramater

I 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 Tbloek

ID ID
Naam Titel
Boek_ID Auteur

the Boek_ID is i an relationship with the ID form tblBoek

SQL:

"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 WHERE

but the books ID doesnt work without it it will

thx!!

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



--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -