Insert data into a table using the INSERT statement
Specify explicit columns where others support defaults or NULLs .
INSERT INTO Product VALUES ("Barang", 100.00, 1);
INSERT INTO Product (Name, Price, Supplier) VALUES ("Benda", 90.00, 2);
INSERT INTO Product (Name) VALUES ("Boom");
INSERT INTO Product VALUES ("Bagus", NULL, DEFAULT);
Both below will be error when executed.
INSERT INTO Product VALUES ("Jelek", "Bukan", 1);
INSERT INTO Product VALUES ("Jelek", 0.00, NULL);
Select data from a table using the SELECT statement
- Specify the columns or expressions you want to return
SELECT * FROM Product;
SELECT ProductID, Name, Price
FROM Product;
- Use aliases for column names in the result set
SELECT
Name AS Product,
Price * 0.9 AS SalePrice
FROM Product;
- Use the WHERE clause to filter rows
SELECT
Name, Price
FROM Product
WHERE Supplier = 2;