Athirah Hazira
Athirah Hazira

Reputation: 473

INSERT into two tables in MS Access 2010

I have two table which is STAFF and LOGIN

STAFF

staffId    - Number
staffName  - Text
staffEmail - Text

LOGIN

staffName  - Text
staffPwd   - Text

My question is, how to execute a query to insert "Name" into STAFF.staffName and LOGIN.staffName

Since i am new to access, can anyone help me out? Any suggestions? Can i use inner join? If so, how?

Note: I am using VB.NET and Access 2010. So the data from the textbox staffName.Text should be inserted into two table (LOGIN & STAFF)

So it will be something like this:

Dim mysql As String = "INSERT INTO STAFF VALUES ('" & txt_id.Text & "', '" & txt_name.Text & "', '" & txt_username.Text & "', '" & txt_username.Text & "', '" & txt_email.Text & "')"

But this is for table STAFF without inserting into LOGIN

Upvotes: 0

Views: 1767

Answers (1)

Pரதீப்
Pரதீப்

Reputation: 93704

If you want to insert data into two tables then you need two separate insert statements.

For STAFF table

INSERT INTO STAFF(staffId,staffName,staffEmail) VALUES (..

For LOGIN table

INSERT INTO LOGIN(staffName,staffPwd) VALUES (..

As a side note you should refer staffId in LOGIN table instead of staffName. Two staff's can have same name

Upvotes: 1

Related Questions