Ask a Question related to Coldfusion Database Access, Design and Development.
-
gabberartist #1
filtering a QUERY with WHERE and a list
this sounds like it should be easy but i'm stuck and i have ran out of ideas.
okay this is what i need done.
in my DB i have a table named links with fileds: link_id , link_name ,
link_url , catagories .
the catagories field has a list of matching catagories. what i want to do now
is when a user clicks on a catagory from a list on a page. i want the query to
look at the list in the catagories field and see if the clicked catagory is
present and only show those results.
query simple example: does not work
<CFQUERY NAME="Links2Get" DATASOURCE="myDB">
SELECT *
FROM links
WHERE catagories LIKE #clickedCatagory#
</CFQUERY>
query w/ output exaple : this works but i want to do it in the query so i
could have the right recordCount
<CFQUERY NAME="Links2Get" DATASOURCE="myDB">
SELECT *
FROM links
</CFQUERY>
<cfif Links2Get.catagories contains '#clickedCatagory#'>
<cfoutput>#link_name# : #link_url#<cfoutput>
</cfif>
gabberartist Guest
-
List to Query
Hi, Can someone please tell me the best way to convert a list into a query? Thanks, Steve -
query to list
i need to convert a query column values to list , is there any way to do that, pls.help thanks in advance. -
Filtering query results
Hi, How do I filter result output data based on WHERE clauses in a query like below. This query should output based upon #FORM.city# OR #URL.city#... -
Convert a query to a list, or find an item in a query
Hi All, I am using CFPOP to retrieve mail from a server, then delete each message after I retrieve it. What I want to do is to check that I don;t... -
List all query names
I'm on a server that does not allow me to look at the normal debuging information. Does anyone know how to loop over all the queries and dump the... -
Explorer5 #2
Re: filtering a QUERY with WHERE and a list
First off, i think you're going to want to put quotes around the
#clickedCategories# variable. The SQL code would look like this..
<CFQUERY NAME="Links2Get" DATASOURCE="myDB">
SELECT *
FROM links
WHERE catagories LIKE '#clickedCatagory#'
</CFQUERY>
I know if your using an Access DB, you will get an error if you do not use
quotes on a field that is set to any type except INTEGER.
Hope that helps!
Explorer5 Guest
-
gabberartist #3
Re: filtering a QUERY with WHERE and a list
thanks but that didn't work .
i need 2 match #clickedCatagory# to a list in the catagories filed in my DB.
gabberartist Guest
-
Explorer5 #4
Re: filtering a QUERY with WHERE and a list
What is the error code you are getting?
Explorer5 Guest
-
-
surenr #6
Re: filtering a QUERY with WHERE and a list
I am not sure whether I got the right understanding of your question but
normally when you use LIKE to do the pattern match then you should use it as
below:
<CFQUERY NAME="Links2Get" DATASOURCE="myDB">
SELECT *
FROM links
WHERE catagories LIKE '%#clickedCatagory#%'
</CFQUERY>
There are other means too, where you can do the SQL query as a click event and
select the categories from the table based on the selected category.
surenr Guest
-
Explorer5 #7
Re: filtering a QUERY with WHERE and a list
In that case, the code is working - it sounds as though the data that is going
through is not the same as what is in the database. Have you double/triple
checked that the data that is being passed is the exact same data that should
be compared against the database (i know it sounds bad.. But i cant tell you
how many times i have double checked, then triple checked, and then the fourth
time, i found i made a mistake).
Explorer5 Guest
-
gabberartist #8
Re: filtering a QUERY with WHERE and a list
thank you very much surenr. i knew it had to be someThing very easy.
gabberartist Guest
-



Reply With Quote

