Posts

Showing posts with the label #13_Understanding8vs*Typo

Understanding the 8 vs. * Typo in SQL

Image
Understanding the 8 vs. * Typo in SQL: Impact and Interview Insights When you mistakenly type a literal (like 8) instead of the wildcard *, SQL interprets it as a constant value rather than an instruction to select all columns. Here's what happens: SELECT 8 FROM EMPLOYEES; This query returns a single column where every row contains the value 8. For example, if there are 107 employees, you’ll get 107 rows with 8 in each row. Why It Happens: In SQL, numeric literals (like 8) are treated as constant expressions. The * operator, on the other hand, is a special symbol that tells SQL to return all columns of the table. If you miss the shift key and type 8 instead, SQL doesn’t know you intended a wildcard—it simply sees a constant. Why It’s an Important Interview Question: Understanding SQL Syntax: It tests whether you know the specific role of the * operator versus a literal value. Attention to Detail: It highlights how a simple typing mistake can completely change the outcome of a quer...