SQL from

Created By: chatGPT

In SQL, the FROM clause is used to specify the tables from which to retrieve data. It indicates the primary source of data for a query. You can select data from one or multiple tables. When joining tables, the FROM clause allows you to establish relationships between them using JOIN operations.
SELECT column1, column2
FROM table_name;
You can also define aliases for tables in the FROM clause for easier referencing. This is particularly useful when dealing with multiple tables.
SELECT a.column1, b.column2
FROM table_name AS a
JOIN another_table AS b ON a.id = b.foreign_id;
If you want to apply conditions on the data retrieved from the tables, you can use the WHERE clause in conjunction with the FROM clause. This combination allows for filtering the results based on certain criteria.
SELECT *
FROM table_name
WHERE condition;
When working with multiple tables, you can utilize various types of joins such as INNER JOIN, LEFT JOIN, RIGHT JOIN, etc., in the FROM clause to showcase how records from different tables relate to each other.
SELECT *
FROM table1
INNER JOIN table2
ON table1.id = table2.table1_id;
In some cases, you may want to retrieve all records from a table regardless of whether there are matching records in another table. This can be achieved using a LEFT JOIN.
SELECT a.column1, b.column2
FROM table1 AS a
LEFT JOIN table2 AS b ON a.id = b.table1_id;
Introduction And SetupSelectFromWhereJoinInner JoinLeft JoinRight JoinFull JoinOnGroup ByHavingOrder ByLimitInsert IntoValuesUpdateSetDeleteCreate TableAlter TableDrop TableCreate IndexDrop IndexUnionUnion AllIntersectExceptCaseWhenThenElseEndInBetweenLikeIs NullIs Not NullExistsNot ExistsAndOrNotAsWithDistinctCountSumAvgMinMaxCastCoalesceNullifSubstringConcatLowerUpperTrimReplaceRoundFloorCeilAbsModCurrent_dateCurrent_timeCurrent_timestamp