As this question is about database queries and not JSP, I'm moving it to our JDBC forum for you.
Please be patient while waiting for an answer. People are in different timezones around the world and it could take up to 24 hours for everyone to see your question. Bumping it with a request for answer doesn't help.
Two other administrative items: 1) Please see David's PM about your display name. 2) "Problem" is not a meaningful subject. It doesn't tell someone thinking about your post anything about the problem. Please use something with more detail new time like "sql query returning duplicates"
author & internet detective
"vamshi", the request that you change your display name to adhere to JavaRanch standards was not a suggestion. Valid display names are mandatory for participation on the Ranch. Please change your display name as instructed prior to your next post.
Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Be aware that accounts with invalid display names are disabled.