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 |
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2005-09-18 : 10:39:55
|
| Hello! I'm working on a "task" application and I need a little help with the database structure. I have 2 tables Tasks and TaskHistoryLets say I have 1 task and it has 2 TaskHistory line entries, What is the best way to return 3 records? Right now, I am only able to return 2.I was thinking it should return the Task, and then the 2 entries under it?SELECT Tasks.TaskID, Tasks.TaskDueDate, Tasks.TaskPriority, Tasks.TaskProgress, Tasks.TaskStatus, Tasks.TaskSummary, Tasks.TaskDescription, Tasks.TaskAssignedTo, TaskHistory.TaskHistoryDescription, TaskHistory.TaskDateModified, TaskHistory.TaskModifiedByFROM Tasks LEFT OUTER JOIN TaskHistory ON Tasks.TaskID = TaskHistory.TaskIDWHERE Tasks.TaskID=1 |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2005-09-18 : 10:47:54
|
| Would it be possible to do everything in 1 table and have a parent/child relationship?For example, the progress will vary from 0% to 100%. In the history, I like to be able to show the progress for each task history step. |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-09-18 : 14:07:52
|
| Are you wanting to return three records, meaning the task followed by task history??? If so, you could use a UNION ALL and have a column called Category. The first piece would have "Task" and just draw all tasks. The second would list task histories and have "Task History" as the Category. You then just order by TaskID and Category. You should be good to go at that point. Give us a little more to work with, and we could probably show you a little easier.http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|
|
|