Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help needed with multiple SQL statement

    Hi,

    I have created a script with displays results based on date range. It all works fine.

    Can anyone point me in the right direct with adding a further statement to the code below, so that I can filter the results by 'LeadState' etc aswell as the date range.

    I have tried to add line 2 ( commented out now) but this does not work.

    MYSQL="select * from DEBT "
    'MYSQL=MYSQL & " WHERE LeadState='RECONTACT' "
    MYSQL=MYSQL & " WHERE EntryDate BETWEEN "
    MYSQL=MYSQL & "#" & varValue1
    MYSQL=MYSQL & "# AND #" & varValue2 & "#;"
    'Response.Write "<HR>" & MYSQL & "<HR>"

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Hi mainprize --

    Here's the answer to your question:

    MYSQL="select * from DEBT "
    'MYSQL=MYSQL & " WHERE (LeadState='RECONTACT') "
    MYSQL=MYSQL & " AND (EntryDate BETWEEN "
    MYSQL=MYSQL & "#" & varValue1
    MYSQL=MYSQL & "# AND #" & varValue2 & "#);"
    'Response.Write "<HR>" & MYSQL & "<HR>"


    Now, unless you are using DAO instead of ADO, the #DATEVAL# for ASP will not work with MySQL. You will have to use the '2007-04-03' version to make this work. It's a pain, and no, you can't change how MySQL formats the date, but you can always use other MySQL and ASP functions to change the date for you.

    HTH!


  •  

    Posting Permissions

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