show records where the model is a "cross cut" type
mysql>
mysql> CREATE TABLE IF NOT EXISTS shredders
-> (
-> model VARCHAR(8) PRIMARY KEY,
-> type VARCHAR(25) DEFAULT "strip cut",
-> price DECIMAL(6,2)
-> );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> INSERT INTO shredders (model, price) VALUES ("PS60", 64.99);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO shredders (model, price) VALUES ("PS70", 99.99);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO shredders (model, type, price) VALUES ("PS400", "cross cut", 64.99);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO shredders (model, price) VALUES ("PS500", 29.95);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # show all data in the "shredders" table
mysql> SELECT * FROM shredders;
+-------+-----------+-------+
| model | type | price |
+-------+-----------+-------+
| PS60 | strip cut | 64.99 |
| PS70 | strip cut | 99.99 |
| PS400 | cross cut | 64.99 |
| PS500 | strip cut | 29.95 |
+-------+-----------+-------+
4 rows in set (0.00 sec)
mysql>
mysql> # show records where the model is a "cross cut" type
mysql> SELECT * FROM shredders WHERE type LIKE "%cross%";
+-------+-----------+-------+
| model | type | price |
+-------+-----------+-------+
| PS400 | cross cut | 64.99 |
+-------+-----------+-------+
1 row in set (0.00 sec)
mysql>
mysql> # delete this sample table
mysql> DROP TABLE IF EXISTS shredders;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
Related examples in the same category