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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,223,630
Messages
6,173,451
Members
452,514
Latest member
cjkelly15

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