Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
deleting rows with same value in a single column
Old 09-12-2010, 07:25 PM deleting rows with same value in a single column
Skilled Talker

Posts: 83
Trades: 0
I have a mysql table that looks like this:

id int(11) autoincrement
artist varchar(50)
title varchar(50)

I need to check for any rows that have the same titles.
So for example, if I had the following rows:

1 - Bob - Hello World
2 - Charlie Brown - Theme Song
3 - Joe - Hello World
4 - Joe - Is Cool
5 - Bob - Magic Dude

The query would display Row 1, and Row 3 as duplicates. Any idea how I can do something like this?
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-12-2010, 07:35 PM Re: deleting rows with same value in a single column
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.justin-cook.com/wp/2006/1...atabase-table/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-12-2010, 08:24 PM Re: deleting rows with same value in a single column
Skilled Talker

Posts: 83
Trades: 0
Alright, I tried this:

PHP Code:
$result mysql_query("SELECT title, COUNT(title) AS n FROM sheets GROUP BY title HAVING n > 1"); 
I have a while loop later on in my code that looks like this:

PHP Code:
while($row mysql_fetch_array($result))[


This is a page that I've been using for weeks and the while loop works great. There must be a problem with this query.

I am not getting any errors, nor anything displaying to the screen.
Smudly is offline
Reply With Quote
View Public Profile
 
Old 09-13-2010, 09:19 AM Re: deleting rows with same value in a single column
Banned

Posts: 408
Name: mushget
Trades: 0
$result = mysql_query("SELECT title FROM sheets GROUP BY title HAVING count(title) > 1");
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Old 09-22-2010, 09:08 AM Re: deleting rows with same value in a single column
Experienced Talker

Posts: 41
Name: vinay
Trades: 0
SELECT DISTINCT title FROM sheets GROUP BY title HAVING count(title) > 1
vinay.desi9n is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to deleting rows with same value in a single column
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14648 seconds with 12 queries