uhm... E mettere il controllo direttamente nella query?
Select * from table where quellochevuoi