Select Query in MySQL
SELECT statement use to select data from a database.
Syntex:-
1) If we have select few specific fields from table.
Select coulmn_name1,coulmn_name2 from table_name;2) If we have to select all records from table.
select * from table_name;Example
If we have a user table in database:
U_id | Uname | Mobile | City |
---|---|---|---|
1 | Raj | RAJPHONE | Ajmer |
2 | Ravi | RAVIPHONE | Jaipur |
3 | Vijay | VIJAYPHONE | Alwar |
SELECT Uname,city FROM user;Output:
U_id | Uname | City |
---|---|---|
1 | Raj | Ajmer |
2 | Ravi | Jaipur |
3 | Vijay | Alwar |
SELECT * FROM user;Output:
U_id | Uname | Mobile | City |
---|---|---|---|
1 | Raj | RAJPHONE | Ajmer |
2 | Ravi | RAVIPHONE | Jaipur |
3 | Vijay | VIJAYPHONE | Alwar |
If we have to SELECT specific data from a user table Where city is Ajmer.
SELECT Uname FROM user WHERE city='Ajmer';Output:
Uname |
---|
Raj |
No comments:
Post a Comment