[RESOLVED] Mysql Query Guidance Needed
I don't work much with mysql, and need input on how to structure a query (or series of query's).
I am working with a task-assignment application, and the table I am trying to query contains records of: employee_num, employee_name, task_assigned, project_num.
The report I am trying to form is based on project_num, & I want to find all employee_names assigned to each task
Assigned to task 1:
Joe Smith, Frank Furter
Assigned to task 2:
Chili Cheesefries, John Doe, Ham Hock
I am stuck on how to structure this report. it seems like it should be easy though, I just need to find out who is assigned to what under each project.
You could do something like this (require MySQL 4.1 or later):
$sql = "
SELECT `task_assigned`, GROUP_CONCAT(`employee_name` SEPARATOR ', ') AS emp_list
WHERE `project_num` = '$projectNum'
GROUP BY `task_assigned`
$result = myql_query($sql) or die("Query failed ($sql): " . mysql_error());
echo "<h2>Project: $projectNum</h2>\n";
while($row = mysql_fetch_assoc($result))
"<li><strong>Assigned to Task %s:</strong><br />%s</li>\n",
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Wow that's it exactly NogDog. Now I have some more studying to do.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)