Using SQL SELECT statement in MySql
SQL 'SELECT' is used to select the data from database. We get the data in a table form which we call result set.
SQL syntax for selecting all columns from MySql database
SELECT * FROM customer;
+----+--------+---------+------+ | ID | FNAME | LNAME | AGE | +----+--------+---------+------+ | 1 | AKSHAY | KUMAR | 12 | | 2 | JONTY | RHODES | 40 | | 3 | JOHNY | DEPP | 45 | | 4 | JESSIE | PINKMAN | 25 | +----+--------+---------+------+as you can see this statement has selected all the 4 rows of the table 'CUSTOMER';
SQL syntax for selecting specified columns from MySql database
We can also select some specified columns only from the table using the below syntax.SELECT FNAME, AGE FROM customer;
+--------+------+ | FNAME | AGE | +--------+------+ | AKSHAY | 12 | | JONTY | 40 | | JOHNY | 45 | | JESSIE | 25 | +--------+------+ 4 rows in set (0.00 sec)As you can see we have just selected FNAME and AGE from CUSTOMER TABLE. We can also use WHERE clause to specify some more conditions to select only some of the rows from the table instead of all the rows of the table. We will learn more about the WHERE clause in next few tutorials.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment