Click here to Skip to main content
15,940,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have two table in sql server .country table and detail table.
detail table a country id more than means that detail table have 10 record
but i want to select only one record from detail table how it is done plz help me that will be greate help
RaisKazi 27-Aug-11 3:59am    
Question is unclear. Can you provide design of your both the tables?

It's difficult to be precise from your description, but have a look at the WHERE clause of the SQL SELECT statement: W3Schools[^]

SELECT * FROM myTable WHERE country='India'
Share this answer
You can always just do a LEFT JOIN on the two tables and select the TOP row.
Share this answer
It is not clear from the problem description if the 10 records of "details" table are related to the same country (entry), or related to all countries (entries).

If the details are for different countries, then you need to use INNER JOIN statement to select each country with its details, but if the 10 details are related to the same country then you have two options:

1. The details are identified, then you can use WHERE statement.
2. The details are not identified and WHERE statement is not applicable. In this case you need to check you database design or unnecessary data redundancy.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900