1064: syntax error near 'and cat_id= order by id' at line 1 select max(id) as id from gallery where id< and cat_id= order by id1064: syntax error near 'and cat_id= order by id' at line 1 select min(id) as id from gallery where id> and cat_id= order by id