--- title: "Common Syntax: SQL" slug: "common-syntax-sql" updated: 2023-07-05T21:29:47Z published: 2023-07-05T21:29:47Z canonical: "docs.interprose.com/common-syntax-sql" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.interprose.com/llms.txt > Use this file to discover all available pages before exploring further. # Common Syntax: SQL This procedure provides an overview of common SQL syntax, including the SELECT, FROM, WHERE and ORDERBY statements. ### SELECT Section The SELECT section specifies the data table and columns you want to retrieve. Use commas to separate multiple data references. For example: ```custom SELECT debt.debt_id, demographic.first_name as "First", -- use aliases to make the column names more readable demographic.last_name as "Last", debt.current_balance / 100.0 as "currentBalance" -- balances are stored in cents, so divide by 100 to get dollars ``` ### FROM Section The FROM section lists the table(s) you are referencing, separated by commas. For example: ```custom FROM debt, demographic ``` Important Note Joining tables in the FROM section without additional clauses can result in a cross join. This combines every row from one table with every row from another table, potentially leading to a large and overwhelming result set. To avoid unintended consequences, it's crucial to use additional clauses like the WHERE clause. These clauses define the relationship between tables and filter the result set based on specific conditions. By specifying criteria, you can narrow down the output to relevant and desired data. It's important to note that mastering table joins requires further learning and practice. Beginners should consult beginner-friendly tutorials or resources for a better understanding of table joins and their proper usage. ### WHERE Section The WHERE section defines criteria to filter rows in the specified table. Without a WHERE statement, the query returns all rows in the table. The example below demonstrates the usage of multiple conditions in a WHERE clause to filter data from different tables in a SQL query. The conditions specify the relationships between the tables and the criteria that must be met for a row to be included in the result set. The code combines logical operators (AND) to link the conditions together and ensure that all conditions are satisfied for a row to be selected. ```custom WHERE debt.debt_id = demographic.debt_id -- Multiple tables require a join condition AND demographic.demographic_type = 'PRIMARY' AND demographic.state = 'WA' -- additional filters ``` ### ORDERBY Section ```custom ORDER BY demographic.last_name -- optionally sort the results ``` ### Full SQL Query Assembling all parts, we get the complete SQL query: ```custom SELECT debt.debt_id, demographic.first_name as "First", -- use aliases to make the column names more readable demographic.last_name as "Last", debt.current_balance / 100.0 as "currentBalance" -- balances are stored in cents, so divide by 100 to get dollars FROM debt, demographic WHERE debt.debt_id = demographic.debt_id -- Multiple tables require a join condition AND demographic.demographic_type = 'PRIMARY' AND demographic.state = 'WA' -- additional filters ORDER BY demographic.last_name -- optionally sort the results ``` ### Example SQL Result ![](https://cdn.document360.io/6c7303ca-5ffc-4149-8868-8ea498eee635/Images/Documentation/example%20sql%20result.png?sv=2026-02-06&spr=https&st=2026-10-31T16%3A38%3A19Z&se=2026-10-31T17%3A38%3A19Z&sr=c&sp=r&sig=sWijv0jdE3e%2FrZ%2BR3Av56xAr1ZpFS1kwWMx8cVH1n%2BE%3D)Image Displays Full SQL Query Example NoteIt is essential to construct queries carefully to avoid system lock-ups or duplicate results. Consider visiting [PostgreSQL](https://www.postgresql.org/) for comprehensive SQL documentation. SQL (Structured Query Language) is a powerful data reference language used for managing relational databases. Tables in SQL have interlinked unique identifying keys and contain multiple data fields (columns) and rows.