Thanks a lot Stuart for your assistance but I figured another way of doing it. I first pulled all the id into an array and then randomly picked 5. And then using 'IN' I picked out the information corresponding to the 5 ids'.
I'll paste it below for anyone to refer to it.
$cresult = mysql_query("SELECT job_id FROM dept, job, type where dept.dept_id=job.job_id AND type.type_id=job.job_id and jobtype='$typeofjob' and approve='yes'", $db);
$count = mysql_num_rows($cresult);
while ($myrow = mysql_fetch_array($cresult))
{
$id[] = $myrow["job_id"];
}
srand((double)microtime()*1000000);
for ($k=0; $k<5; $k++)
{
$random[$k]=(rand (1,$count));
$temp[$k] = $id[$random[$k]];
}
$temp = implode (",", $temp);
$sql = "SELECT * FROM dept, job, type WHERE dept.dept_id=job.job_id AND type.type_id=job.job_id AND jobtype='$typeofjob' AND approve='yes' AND job_id IN ($temp)";
$result = mysql_query($sql,$db);
while ($myrow = mysql_fetch_array($result))
Have fun
Tejas