The SQL SELECT StatementThe SELECT statement is used to select data from a database.The data returned is stored in a result table, called the result-set.SELECT Syntax
SELECT [i]column1[/i],[i] column2, …[/i]
FROM [i]table_name[/i];
Here, column1, column2, … are the field names of the table you want to select data from. If you want to select all the fields available in the table, use the following syntax:
SELECT * FROM [i]table_name[/i];
[hr]
Demo DatabaseBelow is a selection from the “Customers” table in the Northwind sample database:
[img]https://e3vkvq.dm2301.livefilestore.com/y4mGRBB0NjV5qbgTxHMFkI2x7Fc1NKQq7lGUHl2ub0Lkn56mDYMXnKBFvBdxDZmAsBa7o4z73hXorGiNvMELeRVMQAI_-A1gnlN1Z4Vzki_F7ltNtbzeOT2QgAGovtEbZzHfrpBDCauAhJ8ug4aeUKDDe4LrhqX8w4KM3Cg_PJ9eP_fSi1nRj_Aa1kAQx6EJOtE8eDAEWnvoGdm0SnnT7JUEQ?width=901&height=347&cropmode=none[/img]
SELECT Column ExampleThe following SQL statement selects the “CustomerName” and “City” columns from the “Customers” table:Example
SELECT CustomerName, City FROM Customers;
Try it Yourself »
[hr]
SELECT * ExampleThe following SQL statement selects all the columns from the “Customers” table:Example
SELECT * FROM Customers;
Try it Yourself »