Select rows : Simple Select « Select Clause « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
SQL / MySQL » Select Clause » Simple Select 
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, rows affected (0.00 sec)

mysql>
mysql> INSERT INTO product maker, model, power )      VALUES ("Sharp""R254SL"800);
Query OK, row affected (0.00 sec)

mysql> INSERT INTO product maker, model, power )      VALUES ("Sharp""R33STM"900);
Query OK, row affected (0.00 sec)

mysql> INSERT INTO product maker, model, power )      VALUES ("Sanyo""EMS3553"900);
Query OK, row affected (0.00 sec)

mysql> INSERT INTO product maker, model, power )      VALUES ("Panasonic""NNE442"900);
Query OK, row affected (0.00 sec)

mysql> INSERT INTO product maker, model, power )      VALUES ("Daewoo""KDR3000"800);
Query OK, row affected (0.00 sec)

mysql>
mysql> # show all data in the "product" database
mysql> SELECT FROM product;
+----+-----------+---------+-------+
| id | maker     | model   | power |
+----+-----------+---------+-------+
|  | Sharp     | R254SL  |   800 |
|  | Sharp     | R33STM  |   900 |
|  | Sanyo     | EMS3553 |   900 |
|  | Panasonic | NNE442  |   900 |
|  | Daewoo    | KDR3000 |   800 |
+----+-----------+---------+-------+
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 |
+----+-------+--------+-------+
|  | Sharp | R33STM |   900 |
+----+-------+--------+-------+
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 |
+----+-----------+--------+-------+
|  | Panasonic | NNE442 |   900 |
+----+-----------+--------+-------+
row in set (0.00 sec)

mysql>
mysql> drop table product;
Query OK, rows affected (0.00 sec)

mysql>
mysql>

   
    
    
    
    
    
    
  
Related examples in the same category
1.Explain select command
2.Get the number, name, and date of birth of each player resident in Stratford; sort the result in alphabetical
3.Do math calculation with select
4.SELECT statement includes three select list elements
5.The expression in the select list subtracts the Reserved value from the total
6.Removing duplicates and selecting only the unique combinations of values in the specified columns
7.Display the names of only those authors whose surname starts with one of the letters L through Z:
8.Determines all employees whose names contain the sequence of letters er.
9.Use a wildcard (*) to return all the fields
10.Using mysql as a Calculator
11.Identifying What Values to Display
12.Using the aliases p1 and p2 to refer to the book table different ways
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.