SQL Insert question

de ware

New Member
Joined
Feb 16, 2010
Messages
49
Hi,

Trying to insert data in an Database using SQL in VBA.
Let's assume i have two tables:

Books -> columns: description / pages / author
Author -> columns: Author_ID / Author

When inserting a new book the table books (using an xls workbook as interface) the user has a listbox where the possible Authorss are loaded.
So i have the 'Author' as a variable but I need to insert the Author_ID in the table books
How this is don in SQL language?

I guess the solution might be something like using 'INNER JOIN' which works for making selections but I cant't find how.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Something like this?

INSERT INTO BOOK (Description, Pages, Author) VALUES ('" & CellA & "','" & CellB & "'," & (SELECT AuthorID FROM AUTHOR WHERE AuthorName='" & CellC & "');
 
Upvote 0

Forum statistics

Threads
1,214,938
Messages
6,122,346
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top