PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

Boolean

← All stacks

Theory

49/439

Boolean

MySQL treats 0 as false and 1 (or non-zero) as true in many boolean contexts. A TINYINT(1) column is a common ‘boolean’. TRUE and FALSE are aliases for 1 and 0.

WHERE passed; means WHERE passed <> 0. Prefer WHERE passed = 1 so readers don’t guess.

Trap — storing ‘yes’/‘no’ strings and comparing to TRUE.

On the example next to this theory — Boolean — wHERE combines predicates with AND/OR; LIKE does pattern match.

Exam tip

TINYINT(1) as 0/1. WHERE passed = 1;

Boolean — sample query

CREATE TABLE products (id INTEGER PRIMARY KEY, name TEXT, price REAL);
INSERT INTO products VALUES (1, 'Pen', 10), (2, 'Book', 200), (3, 'Bag', 50);
SELECT * FROM products
WHERE price BETWEEN 20 AND 150 AND name LIKE 'B%';

Boolean — wHERE combines predicates with AND/OR; LIKE does pattern match.

Short notes

  • Def0 false, non-zero true. TRUE=1 FALSE=0.
  • RulePrefer = 1 / = 0 on a TINYINT flag.
  • Trapyes/no strings as booleans.

Questions

1

How does MySQL store true/false?

49 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.