Show all records where the color is "Silver" and the price is above 100.00
mysql>
mysql> CREATE TABLE IF NOT EXISTS product
-> (
-> id INT AUTO_INCREMENT PRIMARY KEY,
-> model VARCHAR(25) NOT NULL,
-> color VARCHAR(25) NOT NULL,
-> price DECIMAL(6,2) NOT NULL
-> );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> # insert 5 records into the "product" table
mysql> INSERT INTO product (model, color, price) VALUES ("Catalina", "Cherry", 349.99);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> INSERT INTO product (model, color, price) VALUES ("Bistro", "Silver", 99.99);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> INSERT INTO product (model, color, price) VALUES ("Michigan", "Silver", 179.99 );
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> INSERT INTO product (model, color, price) VALUES ("Oregon", "Silver", 199.99);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> INSERT INTO product (model, color, price) VALUES ("Medina", "Black", 159.99);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # show all data in the "product" table
mysql> SELECT * FROM product;
+----+----------+--------+--------+
| id | model | color | price |
+----+----------+--------+--------+
| 1 | Catalina | Cherry | 349.99 |
| 2 | Bistro | Silver | 99.99 |
| 3 | Michigan | Silver | 179.99 |
| 4 | Oregon | Silver | 199.99 |
| 5 | Medina | Black | 159.99 |
+----+----------+--------+--------+
5 rows in set (0.00 sec)
mysql>
mysql> #
mysql> SELECT * FROM product
-> WHERE color = "Silver" AND price > 100.00;
+----+----------+--------+--------+
| id | model | color | price |
+----+----------+--------+--------+
| 3 | Michigan | Silver | 179.99 |
| 4 | Oregon | Silver | 199.99 |
+----+----------+--------+--------+
2 rows in set (0.00 sec)
mysql>
mysql> # delete this sample table
mysql> DROP TABLE IF EXISTS product;
Query OK, 0 rows affected (0.00 sec)
Related examples in the same category