change sql to read from same database