@cali_green
To insert a value into a record in MySQL, you can use the INSERT INTO
statement. Here's an example:
Suppose you have a table called "users" with columns "id", "name", and "email". To insert a value into a new record, you can execute the following SQL statement:
1
|
INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com'); |
This will insert the values 'John Doe' and 'john@example.com' into the corresponding columns "name" and "email" of the "users" table. The "id" column may be automatically generated if it is a primary key with the AUTO_INCREMENT attribute.
You can also insert multiple records at once by extending the VALUES
clause with multiple sets of values:
1 2 3 4 |
INSERT INTO users (name, email) VALUES ('John Doe', 'john@example.com'), ('Jane Smith', 'jane@example.com'), ('Mike Johnson', 'mike@example.com'); |
This will insert three records into the "users" table at once.