user237462
user237462

Reputation: 421

SQL - Return row if Boolean is True

Im trying to create an SQL Statement that will differentiate between employees types. For example if the Boolean Type Manager Column is checked it will return. Im using the info to fill a Manager on Duty JCombo in Java.

Im trying

String sql = "SELECT Employees.Name FROM Employees WHERE Manager = 'true' ORDER BY Name ASC";

Cant seem to get it right.

Upvotes: 0

Views: 1738

Answers (2)

apomene
apomene

Reputation: 14389

in SQL a boolean field is a bit field (0 or 1) so you have to check as:

String sql = "SELECT Employees.Name FROM Employees WHERE Manager = 1 ORDER BY Name ASC"

Upvotes: 0

Mattgb
Mattgb

Reputation: 428

In SQL the boolean field will be a bit so your SQL statement will need to be

String sql = "SELECT Employees.Name FROM Employees WHERE Manager = 1 ORDER BY Name ASC";

Upvotes: 1

Related Questions