Ask a Question related to Coldfusion Database Access, Design and Development.
-
ca_nimrod #1
Need help formatting syntax for SELECT query on a Bittype data field
:confused; I have been trying to build a SQL statement in my coldfusion page
that queries our SQL Server database for a bunch of records. I want to
eliminate a subset of those records based on the value of a field (the field
type in SQL Server is Bit). I have tried to compare the returned value to 0,
'0', '%0%' etc. I cannot seem to find the right syntax to compare it as a true
boolean (i.e., d.fieldname is TRUE).
This is driving me nuts because I am sure it is something really simple. I
cannot find anything online about how ColdFusion/SQL makes that boolean value
validation.
Any help is most appreciated, the code is below d.field3 is the Bit type field.
SELECT d.field1, d.field2, d.field3, dt.doctype, s.section
FROM document d
INNER JOIN DocumentTypes dt ON (d.doctype = dt.doctype)
INNER JOIN Section s ON (d.section = s.section)
WHERE d.field2 LIKE '%data1%'
OR d.field2 LIKE '%data2%'
OR d.field2 LIKE '%data3%'
AND d.field3 = 0
-ca-nimrod
ca_nimrod Guest
-
Select a list of items into an aliased field when doinga select
OK I know this is going to sound weird, but I'm wondering if this is possible. I have a task table. (tblTask) These tasks can be assigned to... -
formatting and syntax
Hi I am all still to new to PERL and I am having trouble playing with formatting my data into a new format. So here is my problem: I have data... -
Data field formatting
how can i make bound column with date format? What should i type in the data field expression property of datagrid? -
SELECT: Syntax error. Please help
When I run this SQL query: SELECT u.*, o.* FROM users u, orders o WHERE TO_DAYS(o.order_date) BETWEEN TO_DAYS('2003-09-20')-10 AND... -
Help with Select Syntax
I created my query, in the query builder, and am now trying to paste it into my module. I don't know how to end a line and let the program know to... -
The ScareCrow #2
Re: Need help formatting syntax for SELECT query on aBit type data field
You do have the correct syntax to compare a bit field
where bit field = 1
where bit field = 0
Are you getting an error, if so what is it ?
If your not getting the results you expect, break the query down. I would
suggest trying without the LIKE's first
SELECT d.field1, d.field2, d.field3, dt.doctype, s.section
FROM document d
INNER JOIN DocumentTypes dt ON (d.doctype = dt.doctype)
INNER JOIN Section s ON (d.section = s.section)
WHERE d.field3 = 0
See if this returns the correct result set.
Ken
The ScareCrow Guest
-
MikerRoo #3
Re: Need help formatting syntax for SELECT query on aBit type data field
As stated by Ken, the syntax, as you posted it, is correct.
However, problems arise in CF when the bit comparison is against a CF variable.
EG AND d.field3 = #SomeYesNoVar#
In that case, you would use <CFQUERYPARAM> (which you should be doing anyway).
Or is the issue that your query works but returns the wrong results?
It looks like you might have wanted:
WHERE
( d.field2 LIKE '%data1%'
OR d.field2 LIKE '%data2%'
OR d.field2 LIKE '%data3%'
)
AND d.field3 = 0
MikerRoo Guest



Reply With Quote

