π§ Welcome to SQL Brain!
Learn SQL. Build skills. Think like a Data Pro.
Here you'll find:
βΈ SQL tips & queries
βΈ SQL concepts made simple
βΈ Interview questions
βΈ SQL challenges
βΈ Beginner β Advanced
Follow @SQLBrainDaily π
Let's master SQL, one query at a time.
NULL in SQL π§
NULL = NULL β not true
NULL != 1 β not true
WHERE col = NULL β returns nothing
Use:
WHERE col IS NULL
WHERE col IS NOT NULL
NULL means "unknown", not zero or empty.
#SQL
Scary SQL moment π¬
UPDATE students
SET city = 'Delhi';
No WHERE clause = every row gets updated!
Safe habit: Run a SELECT with the same WHERE condition first. Verify the rows, then UPDATE.
One missing WHERE can change the whole table!
#SQL#SQLTips
SQL tip.
LIMIT 2 OFFSET 3 skips 3 rows, then returns 2.
Always add ORDER BY, otherwise the rows you get are not guaranteed.
SELECT * FROM Employees
ORDER BY EmployeeID
LIMIT 2 OFFSET 3;
#SQL
@Nikita26rai That semicolon after USERS is the culprit. DELETE runs on the whole table without a WHERE so it crawls. Move the ; to the end: DELETE FROM users WHERE id = 17623;
SQL recap of the week π§
β COUNT(col) and AVG ignore NULLs
β WHERE filters rows, HAVING filters groups
β Join on keys, not on city-like columns
β Check row counts before and after a JOIN
β Use >= and < for date ranges, not BETWEEN
Which one got you? π
#SQL