select site.siteid, hist_site, hist_extn, hist_pargrp, hist_extgrp, hist_jobno, hist_date, hist_time, hist_name, hist_updno, hist_updop, hist_line0, hist_line1, hist_line2, hist_line3, hist_line4, hist_line5 from dirhist, site where hist_updop matches "[adcm]" and hist_date >= "22/01/2009" and hist_date <= "22/01/2009" and hist_extn = 57005 and site.sitenm1[1,4] = hist_site order by hist_date, hist_time select site.siteid, hist_site, hist_extn, hist_pargrp, from dirhist, site where hist_date = \"%s\" and hist_time = \"%s\" and hist_updop = \"m\" and hist_name = \"%s\" and hist_updno = %d and site.sitenm1[1,4] = hist_site