SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 duplicate entries of a column name
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sonia_newbie
Starting Member

India
17 Posts

Posted - 03/13/2013 :  15:56:33  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 03/13/2013 :  16:03:19  Show Profile  Visit webfred's Homepage  Reply with Quote
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

India
17 Posts

Posted - 03/13/2013 :  16:14:37  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 03/13/2013 :  16:27:54  Show Profile  Visit webfred's Homepage  Reply with Quote
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

India
17 Posts

Posted - 03/13/2013 :  17:10:43  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8765 Posts

Posted - 03/13/2013 :  17:17:24  Show Profile  Visit webfred's Homepage  Reply with Quote
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

USA
1974 Posts

Posted - 03/13/2013 :  17:18:18  Show Profile  Visit chadmat's Homepage  Reply with Quote
This is a SQL Server forum, not MySQL

-Chad
Go to Top of Page

sonia_newbie
Starting Member

India
17 Posts

Posted - 03/13/2013 :  17:35:43  Show Profile  Reply with Quote
No problem!!Thankyou guys for your feedback!!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000