14.7k views
5 votes
Write an INSERT statement that adds these rows to the Invoice_Line_Items table:

invoice_sequence: 1 2
account_number: 160 527
line_item_amount: $180.23 $254.35
line_item_description: Hard drive Exchange Server update
Set the invoice_id column of these two rows to the invoice ID that was generated
by MySQL for the invoice you added in exercise 4.

User Micahmills
by
5.6k points

2 Answers

3 votes

Final answer:

To add rows to the Invoice_Line_Items table, use an INSERT statement specifying each column's values, and replace 'YOUR_INVOICE_ID_HERE' with the actual invoice ID obtained from a previous operation.

Step-by-step explanation:

To write an INSERT statement that adds rows to the Invoice_Line_Items table, you need to specify the values for each column as per the given data. Assuming you already have an invoice ID from a previous INSERT statement (exercise 4), the SQL command would look something like this:

INSERT INTO Invoice_Line_Items (invoice_sequence, account_number, line_item_amount, line_item_description, invoice_id)
VALUES
(1, 160, 180.23, 'Hard drive', YOUR_INVOICE_ID_HERE),
(2, 527, 254.35, 'Exchange Server update', YOUR_INVOICE_ID_HERE);

Replace YOUR_INVOICE_ID_HERE with the actual invoice ID that you have obtained from the earlier operation. This statement inserts two rows into the table with the desired values for each column.

User Scuzzy
by
5.0k points
7 votes

Answer:

Insertion query for first row :

INSERT into Invoice_Line_Items (invoice_sequence, account_number, line_item_amount, line_item_description) Values (1, 160, '$180.23', "Hard drive Exchange");

Insertion query for second row :

INSERT into Invoice_Line_Items (invoice_sequence, account_number, line_item_amount, line_item_description) Values (2, 527, '$254.35', "Server update");

Explanation:

* In SQL for insertion query, we use INSERT keyword which comes under DML (Data manipulation Language).

* Statement is given below -

INSERT into Table_name (column1, column2, ....column N) Values (value1, value2, .....value N);

* With the use of INSERT query we can insert value in multiple rows at a same time in a table which reduces our work load.

User Brian Pressler
by
5.4k points