And price >= And price <= Ken [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => The ScareCrow [ip] => info@krcaldwell [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> SOS! Query Question - Coldfusion Database Access

SOS! Query Question - Coldfusion Database Access

Hi thanks for reading my message. I am totally a novice in coldfusion, just started learning couple of weeks back. I wanted to do a query but I just can't figure out how to do, would truly appreciate if you could help... What I want: I got a database with a column in currency (price). I got a search interface that allows user to key in lowest and highest price and the price will then display. How should I write the query in the action page to retrieve what has been keyed in the FORM? Eg. If one enters 50 ...

  1. #1

    Default SOS! Query Question

    Hi thanks for reading my message.

    I am totally a novice in coldfusion, just started learning couple of weeks
    back.
    I wanted to do a query but I just can't figure out how to do, would truly
    appreciate if you could help...

    What I want:
    I got a database with a column in currency (price).
    I got a search interface that allows user to key in lowest and highest price
    and the price will then display.

    How should I write the query in the action page to retrieve what has been
    keyed in the FORM?
    Eg. If one enters 50 as lowest price in the Form, the cfoutput will display
    data with price of 50 and above.

    Pls help...

    Many thanks in advance.
    Rgds,
    Cold and Confusion soul



    design in progress Guest

  2. #2

    Default Re: SOS! Query Question

    Assuming both lower and upper price fields are required

    Select *
    From MyTable
    Where price Between <cfqueryparam value="#form.lowerprice#"
    cfsqltype="CF_SQL_MONEY"> And <cfqueryparam value="#form.upperprice#"
    cfsqltype="CF_SQL_MONEY">


    Assuming only the lower price is required

    Select *
    From MyTable
    Where price >= <cfqueryparam value="#form.lowerprice#"
    cfsqltype="CF_SQL_MONEY">
    <cfif IsDefined("form.upperprice") And Len(Trim(form.upperprice)>
    And price <= <cfqueryparam value="#form.upperprice#" cfsqltype="CF_SQL_MONEY">
    </cfif>

    Assuming niether field is required
    Select *
    From MyTable
    Where 0=0 <!-- zero equals zero --->
    <cfif IsDefined("form.lowerprice") And Len(Trim(form.lowerprice)>
    And price >= <cfqueryparam value="#form.lowerprice#" cfsqltype="CF_SQL_MONEY">
    </cfif>
    <cfif IsDefined("form.upperprice") And Len(Trim(form.upperprice)>
    And price <= <cfqueryparam value="#form.upperprice#" cfsqltype="CF_SQL_MONEY">
    </cfif>

    Ken

    The ScareCrow Guest

Similar Threads

  1. Query Question Please HELP
    By flooker in forum Coldfusion Database Access
    Replies: 4
    Last Post: June 26th, 04:45 PM
  2. Query Question
    By Jason MacKenzie in forum Coldfusion - Advanced Techniques
    Replies: 51
    Last Post: November 18th, 04:58 AM
  3. 6.1 Query of Query Question. Ref to own Col
    By smcgovern in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: April 24th, 10:17 PM
  4. SQL query question
    By Joost Kraaijeveld in forum PostgreSQL / PGSQL
    Replies: 6
    Last Post: February 3rd, 11:48 AM
  5. ASP SQL query question
    By Brandon in forum ASP Database
    Replies: 6
    Last Post: May 3rd, 04:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •