Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Nemec
Starting Member
2 Posts |
Posted - 2011-05-06 : 12:40:51
|
| I have data that I am pulling from 1 table (ProductTraining_Quizes)that I would like to compare to data in a 2nd table(Employee)& then pull additional data from table2 (First & Last name).My Query titled "Quiz" pulls all columns from the 1st table, but when I query for the Employee_ID with Query "Employee_Name" to pull the First & Last Names, my code only pulls the 1st Employee Name & gives that data for all remaining records. What am I missing?<cfquery name="Quiz" datasource="Training">SELECT *FROM dbo.ProductTraining_QuizesORDER BY Entered ASC, CourseNumber</cfquery><cfquery name="Employee_Name" datasource="Training">SELECT Employee_ID, Last_Name, First_Name FROM dbo.EmployeeWHERE Employee_ID = #Quiz.Employee_ID#</cfquery> |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-05-06 : 13:34:29
|
| [code]<cfquery name="Quiz" datasource="Training">SELECT e.Employee_ID, e.Last_Name, e.First_Name, q.*FROM dbo.Employee eJOIN dbo.ProductTraining_Quizes qOn q.Employee_ID = e.Employee_IDWHERE e.Employee_ID = #Quiz.Employee_ID#</cfquery>[/code]I'm not a Cold Fusion guy, but this looks like what you want. |
 |
|
|
Nemec
Starting Member
2 Posts |
Posted - 2011-05-06 : 13:59:01
|
| Russell,THANK YOU!! I have been working on this code for hours now. The only think I had to change in your code was the WHERE statement. You had: WHERE e.Employee_ID = #Quiz.Employee_ID# and I had to change it to WHERE e.Employee_ID = q.Employee_ID.Thank you again!!!!! |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-05-06 : 14:03:43
|
| Glad to help :)Actually, you can remove the where clause altogether in that case. It is already joining on those. I thought maybe the #quiz.employeeid# was a CF variable. |
 |
|
|
|
|
|