id should be autoincremented as a primary key so no need to specify it. If you want to do it inline as you have attempted, I don’t think a hyphen is the right syntax, it would be an equals, as in email='email'
Explicitly listing the column names like this means you can specify the Column names followed by VALUES in any order. You could also miss out the column names and just say:
INSERT INTO users
VALUES ('email', 'name', 'blaa', 'befbf');
Where the values are listed in the order that the columns are defined. Doing it this way, the order becomes important.
You don’t need to specify "field={value}", just put in the values in the proper order.
INSERT INTO Table (Field1,…, FieldN)
VALUES (‘Value1′,….,’ValueN’);
You need to split up the columns and VALUES into separate statements (also the id should get added automatically since you have it as an identity, so you don’t need to explicitly use it).
4
Answers
Try
id
should be autoincremented as a primary key so no need to specify it. If you want to do it inline as you have attempted, I don’t think a hyphen is the right syntax, it would be an equals, as inemail='email'
Explicitly listing the column names like this means you can specify the Column names followed by VALUES in any order. You could also miss out the column names and just say:
Where the values are listed in the order that the columns are defined. Doing it this way, the order becomes important.
You may find this quite useful
The correct command:
You are getting null as sql format is wrong. Id is 1 because that is auto incremented as defined by you. But other columns are null or 0.
You don’t need to specify "field={value}", just put in the values in the proper order.
INSERT INTO Table (Field1,…, FieldN)
VALUES (‘Value1′,….,’ValueN’);
https://www.w3schools.com/mysql/mysql_insert.asp
You need to split up the columns and
VALUES
into separate statements (also the id should get added automatically since you have it as an identity, so you don’t need to explicitly use it).Try this:
You can use this to insert multiple values at once if you need to
(Etc.)