EasyCFM.COM ColdFusion Forums / General Discussion / <cfquery> help

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: <cfquery> help

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

chuck
11-17-2003 @ 1:42 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 113
Joined: Jul 2003

The query below works but I need it to pull out info from a specified quarter. The user would select 'Jan - March' from a drop down menu witch would be passed as a URL to the page that has this query on it, also select people with ages '18 - 25'. Can anyone help with this?

<cfquery name="myname" datasource="mydsn">
SELECT tbl_Info.Gender, tbl_Info.Age, tbl_Lab.Results
FROM tbl_Info INNER JOIN tbl_Lab ON tbl_Info.ID = tbl_Lab.ID WHERE tbl_Info.Gender = 'Male' AND tbl_Info.Age = '?' AND tbl_Lab.Result = 'Negitive'
</cfquery>

Thanks in advance
-Chuck

GTIMANiac
11-17-2003 @ 1:52 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 291
Joined: Feb 2003

Well I do not see where your DATE qualifer would come from but for the age I would do something like this.


<cfquery name="myname" datasource="mydsn">
     SELECT TI.Gender, TI.Age, TL.Results
          FROM tbl_Info TI
               INNER JOIN tbl_Lab TL ON TI.ID = TL.ID
          WHERE TI.Gender = 'Male'
          AND TI.Age BETWEEN 18 AND 25
          AND TL.Result = 'Negitive'
</cfquery>


chuck
11-17-2003 @ 2:10 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 113
Joined: Jul 2003

Well I have a program entry date I guess I could use that.
So add tbl_Info.edate to the query.

GTIMANiac
11-17-2003 @ 2:14 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 291
Joined: Feb 2003

What are your Date Fields and are they datetime or smalldatetime datatypes?

chuck
11-17-2003 @ 2:32 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 113
Joined: Jul 2003

The date field would be 'edate'. I dont have a datetype on it because it gets it's value from a calander in the format of '11/17/2003'

GTIMANiac
11-17-2003 @ 2:56 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 291
Joined: Feb 2003

Just add eDate to the query where needed with something like

AND eDate BETWEEN '11/1/2003' AND '12/1/2003'

Obviously this will not work for you exactly but you should get the point and be able to add your conditional satements into the query.

chuck
11-17-2003 @ 3:18 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 113
Joined: Jul 2003

Thanks for the help it works fine


Website Designed and Developed by Pablo Varando.