2 AND
id NOT IN (SELECT DISTINCT MenuId FROM usermenus WHERE CoId = \'$coid\' AND UserId = \'$userid\')
UNION ALL
SELECT id, parent_id, title, groupmenu, ulvl, 1 AS mtype FROM menus WHERE id LIKE \'$id%\' AND ulvl > 2 AND
id IN (SELECT DISTINCT MenuId FROM usermenus WHERE CoId = \'$coid\' AND UserId = \'$userid\')
UNION ALL
SELECT id, parent_id, title, groupmenu, ulvl, 2 AS mtype FROM menus WHERE id LIKE \'$id%\' AND ulvl = 2
) AS q
ORDER BY id
";$rs=odbc_exec($conn1,$sql);echo "";$i=1;while($r=odbc_fetch_array($rs)){ ?>