Skip to main content
Participant
May 21, 2007
Question

WHERE CLAUSE

  • May 21, 2007
  • 3 replies
  • 291 views
I am trying to use two elements of the WHERE Clause. Please see below. It does not work. My objective is too only pull records that are active. Is this possible.


<CFquery name="PART" datasource="GTRACK2">
Select *
From PARTNR
WHERE id = #id# AND PNSTATUS = "ACTIVE"
ORDER BY ID
</cfquery>

Respectfully
George
This topic has been closed for replies.

3 replies

Participant
May 22, 2007
Thank you very much for the advice.

Gunner George
Inspiring
May 21, 2007
<CFquery name="PART" datasource="GTRACK2">
Select *
From PARTNR
WHERE id = #id# AND PNSTATUS = "ACTIVE"
ORDER BY ID
</cfquery>

I hear very good thing about "Teach Yourself SQL in 10 minutes" by Ben
Forta.

Wrong Quotes. SQL uses single quotes only for string literals.

<CFquery name="PART" datasource="GTRACK2">
Select *
From PARTNR
WHERE id = #id# AND PNSTATUS = 'ACTIVE'
ORDER BY ID
</cfquery>

Also 'Select *' is not a very good practice. It will often mean
selecting more data, sometimes much more data, then is required. And in
some cases could cause problems with ColdFusion. CF will cache the
table layout when 'Select *' is used and not always recognize the table
has changed when columns are added or removed.

tclaremont
Inspiring
May 21, 2007
Try this:

<CFquery name="PART" datasource="GTRACK2">
Select *
From PARTNR
WHERE id = '#id#' AND PNSTATUS = "ACTIVE"
ORDER BY ID
</cfquery>