Where boolean and broken query wizard

Discuss the database features
Post Reply
claytoncramer
Posts: 6
Joined: Mon Oct 08, 2018 6:59 am

Where boolean and broken query wizard

Post by claytoncramer »

Importing my spreadsheet was easy, but when I used the query wizard, I asked to see records where year =1911 (or "1911" in case someone was confused about its type), I got all records. Here is the SQL the wizard created:

Code: Select all

SELECT "MassMurder"."ID" AS "ID", "MassMurder"."month" AS "month", "MassMurder"."date" AS "date", "MassMurder"."year" AS "year", "MassMurder"."city" AS "city", "MassMurder"."state" AS "state", "MassMurder"."dead victim count" AS "dead victim count", "MassMurder"."undead victim count" AS "undead victim count", "MassMurder"."suicide?" AS "suicide?", "MassMurder"."UNKNOWN" AS "UNKNOWN", "MassMurder"."AX" AS "AX", "MassMurder"."HATCHET" AS "HATCHET", "MassMurder"."KNIFE" AS "KNIFE", "MassMurder"."OTHER SHARP" AS "OTHER SHARP", "MassMurder"."BLUNT" AS "BLUNT", "MassMurder"."EXPLOSIVE" AS "EXPLOSIVE", "MassMurder"."POISON" AS "POISON", "MassMurder"."STRANGLE" AS "STRANGLE", "MassMurder"."DROWN" AS "DROWN", "MassMurder"."ARSON" AS "ARSON", "MassMurder"."HANG" AS "HANG", "MassMurder"."OTHER" AS "OTHER", "MassMurder"."FIREARM (unidentified)" AS "FIREARM (unidentified)", "MassMurder"."shotgun" AS "shotgun", "MassMurder"."rifle" AS "rifle", "MassMurder"."pistol" AS "pistol", "MassMurder"."machine gun" AS "machine gun", "MassMurder"."cause" AS "cause", "MassMurder"."category" AS "category" FROM "MassMurder" "MassMurder"
Shouldn't there be a WHERE clause? So I added "where "MassMurder"."year" = 1911" to the SQL and saving it worked. When I wanted to add another WHERE clause to test for boolean values:

Code: Select all

 where "MassMurder"."AX" = On OR "MassMurder"."HATCHET" = On
I tried TRUE, 1, On. What should I be testing against?
OpenOffice 4.1.6
User avatar
robleyd
Moderator
Posts: 5086
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Where boolean and broken query wizard

Post by robleyd »

What type are the fields you want to select?
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Where boolean and broken query wizard

Post by UnklDonald418 »

For each FROM you can have a single WHERE clause.
Assuming "MassMurder"."year" is a numeric type field plus "MassMurder"."AX" and "MassMurder"."HATCHET" are Boolean fields, try

Code: Select all

WHERE "MassMurder"."year" = 1911 
AND  ("MassMurder"."AX" = TRUE OR "MassMurder"."HATCHET" = TRUE)
If "MassMurder"."year" is text then use '1911'
 Edit: If "MassMurder"."date" is a Date type field in the table "MassMurder", try this where clause

Code: Select all

WHERE YEAR("MassMurder"."date") = 1911 
AND  ("MassMurder"."AX" = TRUE OR "MassMurder"."HATCHET" = TRUE)
 
Last edited by UnklDonald418 on Mon Oct 08, 2018 10:16 pm, edited 2 times in total.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
UnklDonald418
Volunteer
Posts: 1549
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Where boolean and broken query wizard

Post by UnklDonald418 »

It just occurred to me, with all those potential search options you should look at this example
[Example #3] Filter/Search with Forms (leveraging SubForms)
Download the sample database "LIKE_user_input_filter.odb"
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Post Reply