Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Sorting data based on mutliple fields
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Not A Guru  
View profile  
 More options Apr 26 2004, 9:36 am
Newsgroups: macromedia.coldfusion.database_access
From: "Not A Guru" <webforumsu...@macromedia.com>
Date: Mon, 26 Apr 2004 13:36:25 +0000 (UTC)
Local: Mon, Apr 26 2004 9:36 am
Subject: Sorting data based on mutliple fields
Hello!

 Ok, so I have 6 possible form text fields the user can enter data in,
corresponding to what they want to sort by. They hit 'submit', then I execute
an SQL <cfquery> in order to find all records that match the criteria entered
in the form.
 Problem is, if they dont enter some data in some fields, the query looks for a
field with data in it, as opposed to by passing it and not including it as part
of the sort. What I want to be able to do is: say I want to find all records
based on three criterea, I enter that data in, and leave the remaining three,
and it finds all records matching my three criterea, ignoring the other three
that were left blank.

 Below is my SQL:

 <cfquery name="list" datasource="hhs">
 Select *
 From Marketing
 WHERE (enquiry_type='#form.enquiry_type#'
 AND state='#form.state#'
 AND country='#form.country#'
 AND method='#form.method#'
 AND method='#form.sendcopy#'
 AND method='#form.editorial#'
 AND method='#form.they_find#'
 AND method='#form.samples#'
 AND prefer='#form.prefer#')
 </cfquery>

 How do I modify that query, such that, if for instance, no data is entered
into any fields, it displays all records in the table, instead of only finding
records where in every field, it has a NULL value (nothing entered in the
field). This is my dilemma.

 Please help

 Thanks buddies

 Not a Guru


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bill_doe  
View profile  
 More options Apr 26 2004, 11:16 am
Newsgroups: macromedia.coldfusion.database_access
From: "bill_doe" <webforumsu...@macromedia.com>
Date: Mon, 26 Apr 2004 15:16:03 +0000 (UTC)
Local: Mon, Apr 26 2004 11:16 am
Subject: Re: Sorting data based on mutliple fields
I'm not a gura either, but check out the code I posted under the "ORA-00911:
invalid character -runs fine in SQLPlus" topic.  I used cfif statements to
include or not include certain form elements based on whether or not they were
left blank.  Don't forget the cfparam's!

 Hope this helps,

 Bill


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
BigDMorris  
View profile  
 More options Apr 27 2004, 11:33 am
Newsgroups: macromedia.coldfusion.database_access
From: "BigDMorris" <webforumsu...@macromedia.com>
Date: Tue, 27 Apr 2004 15:33:53 +0000 (UTC)
Local: Tues, Apr 27 2004 11:33 am
Subject: Re: Sorting data based on mutliple fields
You write it like this:

 <cfquery name="list" datasource="hhs">
 Select *
 From Marketing
 WHERE (enquiry_type='#form.enquiry_type#'
 <CFIF FORM.State IS NOT "">
   AND state='#form.state#'
 </CFIF>
 <CFIF FORM.Country IS NOT "">
   AND country='#form.country#'
 </CFIF>
 etc.
 etc.
 etc.

 Dave Morris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »