On executing the following query I am getting multiple records as result with each having id=10. If I am using distinct keyword, then I should get just one record. What could be the cause?
"select distinct(id) from tablename where id="10"
You really should provide some test data, and let us know which SQL you are using (TSQL/MySQL/psql). By your tags, I assume your using psql.
Acording to the Postgres Docs you should do something like this:
select distinct id from tablename where id="10"
This will just return one row/col that contains 10 if there is one in your table, if you want all the different varieties of rows where id="10" in your table without any duplicates, than you can do:
select distinct * from tablename where id="10"
Your syntax appears to be calling distinct as a function, not an sql keyword look at this
Also, if "id" is really an id for your rows, perhaps you should consider making it a primary key. Then there will only be one row with that value allowed in the table.