added conditions in 'select' sql query