Hello, !

SELECT

SELECT is used to determine which fields will be retrieved from the database.

Common Uses

SELECT * will select all available columns across all tables in your query, including joined tables

SELECT table.* will select all available columns on the specified table. This is useful when you're joining to another table for filtering, but only want to see the columns on one table.

SELECT table.column will select only a single field from a single table. You can leave out the table name if you're only querying a single table.

Examples

SELECT * FROM tablename; -- select everythingSELECT field FROM tablename; -- select a single fieldSELECT field1, field2 FROM tablename; -- select a multiple fieldsSELECT COUNT(*) FROM tablename; -- select the number of rows in a table

AS

AS is used to create an alias. When used with SELECT, it is used to create an alias for a field. When used alongside FROM, AS will create an alias for a table name.