|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I have the following three queries and I want ot simplify them so that they don't take forever to run on the server. If someon could help I would appreciate it soo much. BTW, we are running CFMX on WIndows 2000.
Queries: <!--- Loop through the number of days, processing one day at a time ---> <cfloop index="i" from="1" to="#numdays#" step="1"> <!--- Select all in/out punches for employee for current loop day ---> <cfquery name="gettime" datasource="Timeclock"> select emptrans.[serial number] AS serialnumber, emptrans.[employee id] AS employeeid, emptrans.[punch date] AS punchdate, emptrans.[punch status] AS punchstatus, emptrans.[punch time] AS punchtime, emptrans.type, employee.ID, employee.name, employee.login from emptrans, employee where employee.login = '#form.login#' and employee.id = emptrans.[employee id] and emptrans.[punch date] = #createodbcdate("#theday#")# and (emptrans.[punch status] = 'I' or emptrans.[punch status] = 'O') order by emptrans.[punch time] </cfquery> <!--- Select all B,H,W,M punches for employee for current day ---> <cfquery name="getother" datasource="Timeclock"> select emptrans.[serial number] AS serialnumber, emptrans.[employee id] AS employeeid, emptrans.[punch date] AS punchdate, emptrans.[punch status] AS punchstatus, emptrans.[punch time] AS punchtime, emptrans.type, employee.ID, employee.name, employee.login from emptrans, employee where employee.login = '#form.login#' and employee.id = emptrans.[employee id] and emptrans.[punch date] = #createodbcdate("#theday#")# and (emptrans.[punch status] <> 'I' and emptrans.[punch status] <> 'O' and emptrans.[punch status] <> 'V' and emptrans.[punch status] <> 'S') order by emptrans.[punch time] </cfquery> <!--- Now get vacation and sick leave time ---> <cfquery name="getvacsick" datasource="Timeclock"> select emptrans.[serial number] AS serialnumber, emptrans.[employee id] AS employeeid, emptrans.[punch date] AS punchdate, emptrans.[punch status] AS punchstatus, emptrans.[punch time] AS punchtime, emptrans.type, employee.ID, employee.name, employee.login from emptrans, employee where employee.login = '#form.login#' and employee.id = emptrans.[employee id] and emptrans.[punch date] = #createodbcdate("#theday#")# and (emptrans.[punch status] = 'V' or emptrans.[punch status] = 'S') order by emptrans.[punch time] </cfquery> I have heard about queries on queries but am not sure how to make it work on this. Again, thanks for any help. Jeff |
|
#2
|
|||
|
|||
|
Well your code doesn't make it clear why you are looping throught numdays and where does the variable 'theday' comes from
Quote:
|
|
#3
|
|||
|
|||
|
Also just a note that this is really an SQL question and doesn't have anything to do with CF. I just point this out because we've started seeing more and more straight SQL questions on this list and I'm trying to keep things as CF-centric as possible.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Simplifying Queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|