Select rows
mysql>
mysql> CREATE TABLE IF NOT EXISTS product
-> (
-> id INT AUTO_INCREMENT PRIMARY KEY,
-> maker VARCHAR(20) NOT NULL,
-> model VARCHAR(20) NOT NULL,
-> power INT NOT NULL
-> );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> INSERT INTO product ( maker, model, power ) VALUES ("Sharp", "R254SL", 800);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO product ( maker, model, power ) VALUES ("Sharp", "R33STM", 900);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO product ( maker, model, power ) VALUES ("Sanyo", "EMS3553", 900);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO product ( maker, model, power ) VALUES ("Panasonic", "NNE442", 900);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO product ( maker, model, power ) VALUES ("Daewoo", "KDR3000", 800);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # show all data in the "product" database
mysql> SELECT * FROM product;
+----+-----------+---------+-------+
| id | maker | model | power |
+----+-----------+---------+-------+
| 1 | Sharp | R254SL | 800 |
| 2 | Sharp | R33STM | 900 |
| 3 | Sanyo | EMS3553 | 900 |
| 4 | Panasonic | NNE442 | 900 |
| 5 | Daewoo | KDR3000 | 800 |
+----+-----------+---------+-------+
5 rows in set (0.00 sec)
mysql>
mysql> # show all data in row 2
mysql> SELECT * FROM product WHERE id = 2;
+----+-------+--------+-------+
| id | maker | model | power |
+----+-------+--------+-------+
| 2 | Sharp | R33STM | 900 |
+----+-------+--------+-------+
1 row in set (0.00 sec)
mysql>
mysql> # show all data in row 4
mysql> SELECT * FROM product WHERE id = 4;
+----+-----------+--------+-------+
| id | maker | model | power |
+----+-----------+--------+-------+
| 4 | Panasonic | NNE442 | 900 |
+----+-----------+--------+-------+
1 row in set (0.00 sec)
mysql>
mysql> drop table product;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
Related examples in the same category