Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

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 Codewalkers Forums Sponsor:
  #1  
Old December 3rd, 2002, 01:34 PM
casa casa is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 20 casa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to casa
SELECT statement help

I have a project that I'm working on and am having trouble figuring out how to build my SELECT statements. Here's some sample data and the report I want to build:
php Code:
Original - php Code
  1.  
  2. developmentPlan table
  3. |-----------------------------------------------|
  4. | name         | dept | development             |
  5. |--------------|------|-------------------------|
  6. | SMITH, JOHN  |   1  | Learn PHP and mySQL     |
  7. | SMITH, JAMES |   1  | Learn Perl and Postgres |
  8. | JONES, FRED  |   2  | Learn ASP and msSql     |
  9. | SMITH, JOHN  |   2  | Learn Perl and Oracle   |
  10. | DOE, JOHN    |   3  | Learn HTML              |
  11. |-----------------------------------------------|
  12.  
  13. trainingRequest table
  14. --------------------------------------------------------------
  15. |               |      | cors/|                              |
  16. | name          | dept | conf | cors/conf name               |
  17. |---------------|------|------|------------------------------|
  18. | SMITH, JOHN   |   1  | CORS | Beginning PHP                |
  19. | SMITH, JOHN   |   1  | CORS | Intermediate PHP             |
  20. | SMITH, JOHN   |   1  | CORS | Advanced PHP                 |
  21. | SMITH, JOHN   |   1  | CORS | Introduction to mySQL        |
  22. | SMITH, JOHN   |   1  | CONF | PHP Conference               |
  23. | SMITH, JOHN   |   1  | CONF | mySQL Conference             |
  24. | SMITH, JOHN   |   1  | CONF | Internet Security Conference |
  25. | SMITH, JAMES  |   1  | CORS | Beginning Perl               |
  26. | SMITH, JAMES  |   1  | CORS | Intermediate Perl            |
  27. | SMITH, JAMES  |   1  | CORS | Advanced Perl                |
  28. | SMITH, JAMES  |   1  | CORS | Introduction to Postgres     |
  29. | SMITH, JAMES  |   1  | CONF | Perl Conference              |
  30. | SMITH, JAMES  |   1  | CONF | Postgres Conference          |
  31. | SMITH, JAMES  |   1  | CONF | Internet Security Conference |
  32. | JONES, FRED   |   2  | CORS | Beginning ASP                |
  33. | JONES, FRED   |   2  | CORS | Intermediate ASP             |
  34. | JONES, FRED   |   2  | CORS | Advanced ASP                 |
  35. | JONES, FRED   |   2  | CORS | Introduction to msSQL        |
  36. | JONES, FRED   |   2  | CONF | ASP Conference               |
  37. | JONES, FRED   |   2  | CONF | msSQL Conference             |
  38. | JONES, FRED   |   2  | CONF | Internet Security Conference |
  39. | SMITH, JOHN   |   2  | CORS | Beginning Perl               |
  40. | SMITH, JOHN   |   2  | CORS | Intermediate Perl            |
  41. | SMITH, JOHN   |   2  | CORS | Advanced Perl                |
  42. | SMITH, JOHN   |   2  | CORS | Introduction to Oracle       |
  43. | SMITH, JOHN   |   2  | CONF | Perl Conference              |
  44. | SMITH, JOHN   |   2  | CONF | Oracle Conference            |
  45. | SMITH, JOHN   |   2  | CONF | Internet Security Conference |
  46. | JONES, GEORGE |   3  | CORS | Beginning PHP                |
  47. | JONES, GEORGE |   3  | CORS | Intermediate PHP             |
  48. | JONES, GEORGE |   3  | CORS | Advanced PHP                 |
  49. | JONES, GEORGE |   3  | CORS | Introduction to Postgres     |
  50. |------------------------------------------------------------|
  51.  
  52. Employee: SMITH, JOHN
  53. Department: 1
  54. Development: Learn PHP and mySQL
  55.  
  56. Courses:
  57.   Beginning PHP
  58.   Intermediate PHP
  59.   Advanced PHP
  60.   Introduction to mySQL
  61.  
  62. Conferences:
  63.   PHP Conference
  64.   mySQL Conference
  65.   Internet Security Conference
  66.  
  67. ------------------------------------------------
  68.  
  69. Employee: SMITH, JAMES
  70. Department: 1
  71. Development: Learn Perl and Postgres
  72.  
  73. Courses:
  74.   Beginning Perl
  75.   Intermediate Perl
  76.   Advanced Perl
  77.   Introduction to Postgres
  78.  
  79. Conferences:
  80.   Perl Conference
  81.   Postgres Conference
  82.   Internet Security Conference
  83.  
  84. ------------------------------------------------
  85.  
  86. Employee: JONES, FRED
  87. Department:2
  88. Development: Learn ASP and msSql
  89.  
  90. Courses:
  91.   Beginning ASP
  92.   Intermediate ASP
  93.   Advanced ASP
  94.   Introduction to msSQL
  95.  
  96. Conferences:
  97.   ASP Conference
  98.   msSQL Conference
  99.   Internet Security Conference
  100.  
  101. ------------------------------------------------
  102.  
  103. Employee: SMITH, JOHN
  104. Department:2
  105. Development: Learn Perl and Oracle
  106.  
  107. Courses:
  108.   Beginning Perl
  109.   Intermediate Perl
  110.   Advanced Perl
  111.   Introduction to Oracle
  112.  
  113. Conferences:
  114.   Perl Conference
  115.   Oracle Conference
  116.   Internet Security Conference
  117.  
  118. ------------------------------------------------
  119.  
  120. Employee: DOE, JOHN
  121. Department:3
  122. Development: Learn HTML
  123.  
  124. Courses:
  125.   No Courses Requested
  126.  
  127. Conferences:
  128.   No Conferences Requested
  129.  
  130. ------------------------------------------------
  131.  
  132. Employee: JONES, GEORGE
  133. Department: 3
  134. Development: No Development Plan entered
  135.  
  136. Courses:
  137.   Beginning PHP
  138.   Intermediate PHP
  139.   Advanced PHP
  140.   Introduction to Postgres
  141.  
  142. Conferences:
  143.   No Conferences Requested
  144.  
  145. ------------------------------------------------


I want the user to be able to search on last name and/or department to narrow the results.

This report will be used by individual employees to get their training requests and by managers to get the training requests by each employee within their department.

As you see, I have 2 different employees named John Smith, one employee with no conferences or courses, and one employee with not development plan

It has been suggested that I have two different sql statements, one for development plan and one for training requests. I think this would work if I didn't have any employees with the same last name.

Also, this data is entered in the database randomly, i.e. all the John Smith, Dept 1's may not be together.

Any suggestions?

Reply With Quote
  #2  
Old December 4th, 2002, 07:22 PM
bob0099 bob0099 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: manchester,n.h.,usa
Posts: 172 bob0099 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: SELECT statement help

i would suggest creating an employee id number for each employee to minimize problems. this way you could select by id # and not worry about names.

Reply With Quote
  #3  
Old December 4th, 2002, 08:12 PM
casa casa is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 20 casa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to casa
RE: SELECT statement help

I'm converting a Perl program which used flat files to PHP/mySQL because some of the reports kept timing out. I have almost 7,000 records in the trainingRequest table, so would be a major ordeal to add user id at this time. Actually there is a userid, but I'm not using it yet.

Looking back at my Perl code, I created had a array with a slot for all the needed fields from each table. I pushed all the idp records that met my filter criteria into this array, then pushed the training request records that met my filter criteria into the same array. After I got the records run through the filters and pushed into the array, I sorted it. The first few fields looked like this:

department|employee name|A(for idp),CORS(for course),CONF(for conference)|course name,conference name,null if idp|etc...

So my array would have all the departments together, then all the employees sorted within that department, then the IDP information first, then all the conferenced they wanted , then all the course they wanted. So then I just plucked them off and started a new section when ever the name changed.

It's just that with so many records, if someone requests a report on all the employees in all the departments in the whole company (which is an option), it might time out.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > SELECT statement help


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 3 hosted by Hostway