views:

105

answers:

1
+1  A: 

What you can do is build the SQL in a dynamic form using the following query:

SELECT GROUP_CONCAT( 
  DISTINCT CONCAT(
    '(select jobid, projectid, desc from jobs where projectid=',
    projectid,
    ' order by jobid limit 5)') 
  SEPARATOR ' union ') AS q 
FROM table_1;

Save the result into a variable, and then execute the saved SQL.

David Rabinowitz