query code