i have mysql table called cm
CREATE TABLE `cm` (
`id` int(10) NOT NULL,
`chit_no` varchar(30) DEFAULT NULL,
`pjt_no` varchar(20) DEFAULT NULL,
`design` varchar(25) DEFAULT NULL,
`item` varchar(25) DEFAULT NULL,
`process` varchar(10) DEFAULT NULL,
`times` int(1) DEFAULT NULL,
`current_position` int(1) DEFAULT NULL,
`current_stage` int(1) DEFAULT NULL,
`qty` int(10) DEFAULT NULL,
`dmg` int(2) DEFAULT NULL,
`bbelt` varchar(10) DEFAULT NULL,
`fdate` date DEFAULT NULL,
`remarks` varchar(500) DEFAULT NULL,
`shift` int(1) DEFAULT NULL,
`date` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
table view

this table contain 100K records. i want to get only rows which has Process=Firing and last_record=1 AND qty>0 and also next record qty=0 for perticular date range
this code i have tried but there are no output.
$sql =mysql_query("SELECT *
FROM cm
WHERE ( process='Firing'
AND qty>0
AND last_record='1'
)
AND 1>(SELECT qty
FROM cm
WHERE id=id+1)
AND fdate BETWEEN '$from' AND '$to'
ORDER BY cm.id,design, item,chit_no")
or die ("err1");
$fromand$to?