PDA

View Full Version : help needed with multiple SQL statement



mainprize
04-03-2007, 01:27 PM
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>"

Daemonspyre
04-03-2007, 03:29 PM
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!