Editing
SQL
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Understanding</span> == A relational database stores data in normalized form to reduce duplication. Instead of repeating a customer's address on every order, the address lives once in a Customers table and orders reference it via a foreign key. This separation is the core idea behind relational design. SQL queries are declarative: you describe ''what'' data you want, not ''how'' to retrieve it. The database engine (PostgreSQL, MySQL, SQLite, SQL Server, etc.) figures out the execution plan. This matters because the same logical query can be executed many different ways � and the engine picks the one it estimates to be cheapest. How a SELECT query executes (logical order, not syntactic order): # '''FROM / JOIN''' � identify and combine the source tables # '''WHERE''' � filter rows before grouping # '''GROUP BY''' � collapse rows into groups # '''HAVING''' � filter groups # '''SELECT''' � compute the output columns # '''ORDER BY''' � sort the result # '''LIMIT / OFFSET''' � slice the result set Understanding this order explains common confusions: you cannot reference a SELECT alias in a WHERE clause (WHERE runs before SELECT), and aggregate functions like COUNT() only become valid after GROUP BY. </div> <div style="background-color: #8B0000; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information