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:
developmentPlan table
|-----------------------------------------------|
| name | dept | development |
|--------------|------|-------------------------|
| SMITH, JOHN | 1 | Learn PHP and mySQL |
| SMITH, JAMES | 1 | Learn Perl and Postgres |
| JONES, FRED | 2 | Learn ASP and msSql |
| SMITH, JOHN | 2 | Learn Perl and Oracle |
| DOE, JOHN | 3 | Learn HTML |
|-----------------------------------------------|
trainingRequest table
--------------------------------------------------------------
| | | cors/| |
| name | dept | conf | cors/conf name |
|---------------|------|------|------------------------------|
| SMITH, JOHN | 1 | CORS | Beginning PHP |
| SMITH, JOHN | 1 | CORS | Intermediate PHP |
| SMITH, JOHN | 1 | CORS | Advanced PHP |
| SMITH, JOHN | 1 | CORS | Introduction to mySQL |
| SMITH, JOHN | 1 | CONF | PHP Conference |
| SMITH, JOHN | 1 | CONF | mySQL Conference |
| SMITH, JOHN | 1 | CONF | Internet Security Conference |
| SMITH, JAMES | 1 | CORS | Beginning Perl |
| SMITH, JAMES | 1 | CORS | Intermediate Perl |
| SMITH, JAMES | 1 | CORS | Advanced Perl |
| SMITH, JAMES | 1 | CORS | Introduction to Postgres |
| SMITH, JAMES | 1 | CONF | Perl Conference |
| SMITH, JAMES | 1 | CONF | Postgres Conference |
| SMITH, JAMES | 1 | CONF | Internet Security Conference |
| JONES, FRED | 2 | CORS | Beginning ASP |
| JONES, FRED | 2 | CORS | Intermediate ASP |
| JONES, FRED | 2 | CORS | Advanced ASP |
| JONES, FRED | 2 | CORS | Introduction to msSQL |
| JONES, FRED | 2 | CONF | ASP Conference |
| JONES, FRED | 2 | CONF | msSQL Conference |
| JONES, FRED | 2 | CONF | Internet Security Conference |
| SMITH, JOHN | 2 | CORS | Beginning Perl |
| SMITH, JOHN | 2 | CORS | Intermediate Perl |
| SMITH, JOHN | 2 | CORS | Advanced Perl |
| SMITH, JOHN | 2 | CORS | Introduction to Oracle |
| SMITH, JOHN | 2 | CONF | Perl Conference |
| SMITH, JOHN | 2 | CONF | Oracle Conference |
| SMITH, JOHN | 2 | CONF | Internet Security Conference |
| JONES, GEORGE | 3 | CORS | Beginning PHP |
| JONES, GEORGE | 3 | CORS | Intermediate PHP |
| JONES, GEORGE | 3 | CORS | Advanced PHP |
| JONES, GEORGE | 3 | CORS | Introduction to Postgres |
|------------------------------------------------------------|
Employee: SMITH, JOHN
Department: 1
Development: Learn PHP and mySQL
Courses:
Beginning PHP
Intermediate PHP
Advanced PHP
Introduction to mySQL
Conferences:
PHP Conference
mySQL Conference
Internet Security Conference
------------------------------------------------
Employee: SMITH, JAMES
Department: 1
Development: Learn Perl and Postgres
Courses:
Beginning Perl
Intermediate Perl
Advanced Perl
Introduction to Postgres
Conferences:
Perl Conference
Postgres Conference
Internet Security Conference
------------------------------------------------
Employee: JONES, FRED
Department:2
Development: Learn ASP and msSql
Courses:
Beginning ASP
Intermediate ASP
Advanced ASP
Introduction to msSQL
Conferences:
ASP Conference
msSQL Conference
Internet Security Conference
------------------------------------------------
Employee: SMITH, JOHN
Department:2
Development: Learn Perl and Oracle
Courses:
Beginning Perl
Intermediate Perl
Advanced Perl
Introduction to Oracle
Conferences:
Perl Conference
Oracle Conference
Internet Security Conference
------------------------------------------------
Employee: DOE, JOHN
Department:3
Development: Learn HTML
Courses:
No Courses Requested
Conferences:
No Conferences Requested
------------------------------------------------
Employee: JONES, GEORGE
Department: 3
Development: No Development Plan entered
Courses:
Beginning PHP
Intermediate PHP
Advanced PHP
Introduction to Postgres
Conferences:
No Conferences Requested
------------------------------------------------
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?