Skip to main content
Inspiring
July 2, 2008
Question

SQL where clause problem

  • July 2, 2008
  • 2 replies
  • 397 views
I'm trying to construct the query dynamically

SELECT *
FROM transmission
WHERE manufacturer="BMW"

* is stored in #client.SQLselect#
transmission is stored in #client.SQLfrom#
BMW is stored in #form.listManufacturer#
where manufacturer="BMW" is what should be stored in #client.SQLwhere# but I can't get this to work...

I've tried this, but it doesn't work
<cfset #client.SQLwhere="where manufacturer=""#form.listManufacturer#""">

Can someone explain how to combine the above on a line so it works ?
This topic has been closed for replies.

2 replies

Inspiring
July 2, 2008
ok, thanks
Inspiring
July 2, 2008
I hope all you want to do is something like:

<cfset client.SQLwhere = "where manufacturer = '" &
form.listManufacturer & "'">

I have no idea what you where attempting to do with all those
pound|hash|# characters.

NOTE: The use of alternating double and singe quotes. This is a very
useful technique in ColdFusion and is worth reading up on in the
documentation.
Inspiring
July 2, 2008
thanks Ian, you're quite right I shouldn't be using all those pound signs!

However, when I tried your solution I found I had to modify the line slightly:
<cfset client.SQLwhere="manufacturer=""" & form.ListManufacturer & """">