Home > Mobile >  Can anyone explain how to properly write the WHERE clause with a True/False element?
Can anyone explain how to properly write the WHERE clause with a True/False element?

Time:12-17

I took two tries at this test and got this question wrong both times. I don't understand how to write the WHERE clause. I thought it didn't need the "" marks as the columns I believe had yes/no values. Is it just the OR that needs to be selected, and does it work with our without the quotations? - I'm just a confused newbie, thanks for any clarification.

You finish cleaning your datasets, so you decide to review Tayen’s email one more time to make sure you completed the task fully. It’s a good thing you checked because you forgot to identify people who have served on the board of directors or board of trustees. She wants to write them a thank-you note, so you need to locate them in the database.

To retrieve only those records that include people who have served on the board of trustees or on the board of directors, what is the correct query?

0 / 1 point

SELECT *
FROM Donation_Form_List
WHERE Board_Member = TRUE AND Trustee = TRUE



SELECT *
FROM Donation_Form_List
WHERE Board_Member = "TRUE" AND Trustee = "TRUE"



SELECT *
FROM Donation_Form_List
WHERE Board_Member = TRUE, Trustee = TRUE



SELECT *
FROM Donation_Form_List
WHERE Board_Member = "TRUE" OR Trustee = "TRUE"

Incorrect

Review the section on SQL functions for a refresher.

CodePudding user response:

SQL doesn't actually have booleans as a data type. It's common to represent True and False values as 1 and 0.

If you actually wanted to store the word True you would need to store it as a VARCHAR which would require quotes to look up.

I think that's what the question is getting at.

CodePudding user response:

If you have two columns with boolean values in database and managing status in those columns then following query should return you data for (board_member trustee)

SELECT * FROM Donation_Form_List 
WHERE 
(Board_Member = True OR Trustee = True)
  • Related