How to update data from two tables

Hello, I’m having a hard to finish this CRUD project that I have because I dont know the proper sintax on how to update the data from two tables.

Here is the tables:

Table Users:

Table Car:
id (foreign key)

Thank you so much

Hi @Ches:

You need to issue two separate insert statements, one for Users and the other on Car.

You could use something like:

INSERT INTO Users (Name, Email) VALUES ('Name', '[email protected]'); INSERT INTO Car (id, Car_Service, Car_Model) VALUES (LAST_INSERT_ID(), 1, 1);

Hi! Should it be really ‘insert into’ and not ‘update’? Thank you

Yes, it’s INSERT because you’re creating a new record (two in this case), UPDATE is used to change something that’s already in the database.

Sponsor our Newsletter | Privacy Policy | Terms of Service