Use the SELECT statement to query data from a table.
Example:
Create Table a that contains the following data:
obclient> CREATE TABLE a (id int, name varchar(50), num int);
Query OK, 0 rows affected (0.07 sec)
obclient> INSERT INTO a VALUES(1,'a',100),(2,'b',200),(3,'a',50);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
obclient> SELECT * FROM a;
+------+------+------+
| ID | NAME | NUM |
+------+------+------+
| 1 | a | 100 |
| 2 | b | 200 |
| 3 | a | 50 |
+------+------+------+
3 rows in set (0.00 sec)
Query the data in the
namefield from Tablea.obclient> SELECT name FROM a; +------+ | NAME | +------+ | a | | b | | a | +------+ 3 rows in set (0.00 sec)Deduplicate the query results of the
namefield.obclient> SELECT DISTINCT name FROM a; +------+ | NAME | +------+ | a | | b | +------+ 2 rows in set (0.00 sec)Return the values of the corresponding
id,name, andnumfields based on the filtering conditionname = 'a'.obclient> SELECT id, name, num FROM a WHERE name = 'a'; +------+------+------+ | ID | NAME | NUM | +------+------+------+ | 1 | a | 100 | | 3 | a | 50 | +------+------+------+ 2 rows in set (0.01 sec)
For more information on the syntax of the SELECT statement, see the "SELECT" topic in SQL Reference (Oracle Mode).