Query to retrieve price

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Query to retrieve price

    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




    Mark this message as the answer.
    Print this message
    Report this to a Moderator
    The ScareCrow
    User is offline
    View Profile

    Senior Member Posts: 3789
    Joined: 07/22/2002
    05/11/2005 06:39:24 AM
    Reply | Quote | Top | Bottom

    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


    design in progress Guest

  2. Similar Questions and Discussions

    1. New project - Price
      Hi I have a customer who wants a price on a flashproject. The result should look something like this: http://www.triumph-international.no Could...
    2. ot - SQL DEV Ed Price drop
      Hi All In the UK. I've just that SQL server Developer's edition has dropped in price! I've got a couple of questions if I may as this & the...
    3. Q Price of MS Pro in SHOPS?
      My sister is in Portland, Oregon. Would anyone know the prices of Memory Stick PRO in shops that she can walk into and buy? 256Mb & 512Mb? Not...
    4. Date comparison :: Original price vs Reduced price :: Access 2000/ASP
      I need some guidance in how to control dates with regards price reductions in my product list inside an Access 2000 database. For instance: 1....
    5. darkroom kit price.
      I have just purchased a second hand kit for $995 (AUSTRALIAN $) which included the following; * LPL C6700 colour head enlarger (w/ neg carrier)...
  3. #2

    Default Re: Query to retrieve price

    Ken,

    What I want:
    if people keyed in lowest price, it will show lowest price.
    if people keyed in highest price, it will highest lowest price.
    if people keyed in both price, it will show the price in between lowest and
    highest price.

    All three conditions should be fulfilled.
    Pls help, and thanks for your earlier reply.

    Anyone knows, pls help me...really appreciate.

    Rgds,
    Desperate



    design in progress Guest

  4. #3

    Default Re: Query to retrieve price

    Well, this is interesting. My post has disapeared and I did not get the email
    to notify me of your post.

    Your post is confusing

    Do both price fields have to be entered ?

    Can you give an example(s) of what you expect the user to enter and the value
    you want to be returned in the query ?

    Ken

    The ScareCrow Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139