I am new to mysql. I have a following code, which is taking bit lot time for execution.
Is there any other way to write the same code in a simple way.
Here we are creating a temporary table y from which we are extracting the desired result. (we have around 5 million recrods database)
$query11=mysql_query("create temporary table y (select agnt,shnm,dtoc,dobt,count(*) as dup from master where agnt='$agnt' and dtoc between '19890401' and '19900331' and stat not in (11,12,84) group by agnt,dtoc,shnm,dobt having dup >1)");
$query12=mysql_query("select a.agnt,a.shnm,a.dtoc,a.dobt from y, master as a where y.agnt = a.agnt and y.shnm = a.shnm and y.dtoc = a.dtoc and y.dobt = a.dobt and a.dtoc between '19890341' and '1990331' and stat not in (11,12,84)");
while ($row=mysql_fetch_array($query12)){ if($row[0]>0){$dup++;}}
..
...
....