TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun · 77.7K subscribers
Post #4634 2.1K
❌ Mistake 2: Forgetting quotes around text

Incorrect:

WHERE city = Pune;


Correct:

WHERE city = 'Pune';


❌ Mistake 3: Using AND when you mean OR

Incorrect if you want either city:

WHERE city = 'Pune'
AND city = 'Mumbai';


A single city value cannot normally be both at the same time.

Correct:

WHERE city = 'Pune'
OR city = 'Mumbai';


Or:

WHERE city IN ('Pune', 'Mumbai');


❌ Mistake 4: Forgetting parentheses

For complex conditions, use parentheses:

WHERE
(city = 'Pune' OR city = 'Mumbai')
AND age > 30;


❌ Mistake 5: Assuming BETWEEN excludes the boundaries

BETWEEN is generally inclusive.

🔹 34. Interview Questions

💡 What is the purpose of WHERE?

WHERE filters rows based on a condition.

💡 What is the difference between WHERE and SELECT?

SELECT → Determines what columns/expressions appear in the result.

WHERE → Determines which rows are included.

💡 How do you check for NULL?

Use:

IS NULL

or:

IS NOT NULL

💡 What is the difference between IN and OR?

IN provides a concise way to test whether a value matches any value in a list.

💡 Is BETWEEN inclusive?

Yes, BETWEEN generally includes both boundary values.

🎯 Practice Questions

Q1. Write a query to retrieve employees whose salary is greater than 50,000.

Q2. Write a query to retrieve customers from Pune or Mumbai.

Q3. Write a query to retrieve products priced between 1,000 and 5,000.

Q4. Write a query to retrieve customers whose phone number is missing.

Q5. Write a query to retrieve orders where the status is Success and the amount is greater than 10,000.

🎯 Key Takeaways

✅ WHERE is used to filter rows.

✅ = checks equality.

✅ <> and != can be used for not equal.

✅ AND requires all specified conditions to be true.

✅ OR requires at least one condition to be true.

✅ IN is useful for matching multiple values.

✅ BETWEEN is useful for ranges and is generally inclusive.

✅ LIKE is used for pattern matching.

✅ % represents a sequence of characters.

✅ _ represents one character.

✅ Use IS NULL and IS NOT NULL for NULL values.

✅ Parentheses make complex AND/OR logic clearer and safer.

🧭 Double Tap ❤️ For More
  • ❤ 6
More from @datasciencefun
  1. Oct 2, 2026Data Visualisation tips for beginners
  2. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  3. Sep 28, 2026🔹 Real-World Data Science Example Suppose you are analyzing sales data. You want to ident…
  4. Sep 28, 2026🚀 Data Science Roadmap 2026 📍 Phase 3: SQL for Data Science 📖 Topic 3 — ORDER BY ORDER…
  5. Sep 28, 2026🎓 𝗛𝗔𝗥𝗩𝗔𝗥𝗗 𝗨𝗡𝗜𝗩𝗘𝗥𝗦𝗜𝗧𝗬 𝗙𝗥𝗘𝗘 𝗢𝗡𝗟𝗜𝗡𝗘 𝗖𝗢𝗨𝗥𝗦𝗘𝗦 😍 Dreaming of…
  6. Sep 27, 2026Complete Data Analytics Mastery: From Basics to Advanced 🚀 Begin your Data Analytics jour…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →