Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 duplicate entries of a column name

Author  Topic 

sonia_newbie
Starting Member

17 Posts

Posted - 2013-03-13 : 15:56:33
I have a big table :first few entries:

NAME start stop model
John 1234 3454 1
Sam 1231 3454 2
Tom 1034 2111 4
Bob 1590 2123 5
Tom 1234 4567 1
Barbe 1234 1247 2
jim 1034 3111 4

I want to display all NAMES which have same start value


required result :

NAME start stop model
John 1234 3454 1
Tom 1234 4567 1
Barbe 1234 1247 2
Tom 1034 2111 4
jim 1034 3111 4

I basically want to display only the duplicated values?
Is that possible?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-03-13 : 16:03:19
how can you know which record is the duplicate and which record is the original one?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

sonia_newbie
Starting Member

17 Posts

Posted - 2013-03-13 : 16:14:37
What you mentioned is right .We dont have distinction between original and duplicates.

My basic requiremnt is to find out whether any name in this table has the same start values or stop values as others.



Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-03-13 : 16:27:54
Not sure but try this:

select * from YourTable
where start in (select start from YourTable group by start having count * > 1)
or stop in (select stop from YourTable group by stop having count * > 1)



Too old to Rock'n'Roll too young to die.
Go to Top of Page

sonia_newbie
Starting Member

17 Posts

Posted - 2013-03-13 : 17:10:43
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '> 1) or stop in (select stop from tablename group by stop having count* > 1)' at line 1
What could be the issue?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-03-13 : 17:17:24
The problem is: we are on MS SQL Sever only in these forums. You are using MySQL and I don't know what is possible in MySQL.


Maybe you can get better help in http://www.dbforums.com/mysql/

Sorry


Too old to Rock'n'Roll too young to die.
Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2013-03-13 : 17:18:18
This is a SQL Server forum, not MySQL

-Chad
Go to Top of Page

sonia_newbie
Starting Member

17 Posts

Posted - 2013-03-13 : 17:35:43
No problem!!Thankyou guys for your feedback!!
Go to Top of Page
   

- Advertisement -