ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 23rd, 2004, 04:27 PM
jgrantham jgrantham is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 6 jgrantham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Simplifying Queries

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

Reply With Quote
  #2  
Old September 27th, 2004, 03:20 PM
kaasu kaasu is offline
Web Developer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 58 kaasu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 1 m 4 sec
Reputation Power: 5
Well your code doesn't make it clear why you are looping throught numdays and where does the variable 'theday' comes from


Quote:
Originally Posted by jgrantham
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

Reply With Quote
  #3  
Old September 27th, 2004, 03:40 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Simplifying Queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway