Answered by:
repeat resulst multiple times in sql query

Question
-
User-807418713 posted
Hello
My Result is showing like this
110
I want as resultset
Column1 Column2
A 110
B 110
C 110
D 110
how to get his resulset
Thursday, July 23, 2020 6:46 AM
Answers
-
User1535942433 posted
Hi Gopi.MCA,
Accroding to your description,I'm guessing that you want to find the duplicate values of the Column2.
You could do just like this:
SELECT Column2 FROM TableName GROUP BY Column2 HAVING COUNT(*) > 1
If you have other problems,you could tell us more details of your requirment clearly.
Best regards,
Yijing Sun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 28, 2020 9:19 AM
All replies
-
User753101303 posted
Hi,
Seems you just want to query from a table using SELECT * FROM YourTable ? I'm not sure how you could just get 110 when trying to do that?
Keep in mind we have no other context than what you told us. Either you are still learning the basics about accessing a database (from previous post it seems you are suing ADO.NET and already have done SQL queries before).
Else we are missing some context to understand which problem you have when trying to do something that seems pretty simple. This 110 value is not some kind of debugging message that was just left rather than showing the actual data you want ???
Thursday, July 23, 2020 11:26 AM -
User364663285 posted
Hi GM,
Maybe your query is getting sum of Column2. Try to rewrite it by putting all respective columns.
Thursday, July 23, 2020 3:44 PM -
User-807418713 posted
Hello
Sorry it was little mistake here is the below
Hello
My Result is showing like this
110
I want as resultset
Column1 Column2
A 110
B 110
C 110
D 110
how to get his resulset
Friday, July 24, 2020 8:30 AM -
User753101303 posted
From old posts it seems you are using Web Forms and know already how to use a GridView? It should be something such as http://www.simplylearnprogramming.com/display-data-in-Asp.net-GridView/55
If it doesn't help, show maybe the minimal amount of code so that we can see what you are doing and how to fix this while keeping the same approach for the time being.
For those using Web Forms I would recommend having a look at https://docs.microsoft.com/en-us/aspnet/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data which was new in 4.5 and got little exposure (seems you want to use ADO.NET rather than, Entity Framework ?)
Edit : ah or what you show is just the result of a SQL query you are running in SQL Server Management Studio? In this case show your current SQL query. SELECT * FROM MyTable should work.
I'm really having a hard time how you could have something like this wrong with more than 500 posts which seems to show you do have already a bit of experience. Keep also in mind that we have no other context than what you explicitly told us.
Friday, July 24, 2020 12:12 PM -
User-1151440187 posted
You should fire the query like :
SELECT column1,column2 FROM table WHERE column2 = '110' ;
Maybe you are looking for this.
Hope this'll helpful to you.
Thanks!
Tuesday, July 28, 2020 4:40 AM -
User1535942433 posted
Hi Gopi.MCA,
Accroding to your description,I'm guessing that you want to find the duplicate values of the Column2.
You could do just like this:
SELECT Column2 FROM TableName GROUP BY Column2 HAVING COUNT(*) > 1
If you have other problems,you could tell us more details of your requirment clearly.
Best regards,
Yijing Sun
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, July 28, 2020 9:19 AM