NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page query to show duplicated entries.

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Reply
 
LinkBack Thread Tools
Old 07-26-2010, 10:40 PM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



query to show duplicated entries.


hello all,

this is what i use to show the the data from mysql.


PHP Code:

// i use this to get the total count for pagination.

$query "SELECT COUNT(*) as num FROM file ";    
$total_pages mysql_fetch_array(mysql_query($query));    
$total_pages $total_pages[num];    

/* my codes continues.................*/   


// i use this to get the data
$sql "SELECT * FROM file ORDER BY topic DESC LIMIT $start$limit";   
$result mysql_query($sql); 

????: NamePros.com http://www.namepros.com/programming/668976-query-to-show-duplicated-entries.html
My question is what do i need to change here to show only duplicated entries according to topic field.

Thanks all.
__________________

Rapidme
(rapidshare application)
baris22 is offline   Reply With Quote
Old 07-26-2010, 10:47 PM   #2 (permalink)
Senior Member
 
defaultuser's Avatar
Join Date: May 2009
Location: In My Head
Posts: 4,219
defaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatnessdefaultuser Has achieved greatness
 



SELECT {fields} FROM file ORDER BY topic DESC LIMIT $start, $limit GROUP BY {fields} HAVING COUNT(*) > 1
__________________

Defaultuser R.I.P.
defaultuser is online now   Reply With Quote
Old 07-26-2010, 10:50 PM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Jan 2007
Posts: 98
baris22 is an unknown quantity at this point
 



Originally Posted by defaultuser View Post
SELECT {fields} FROM file ORDER BY topic DESC LIMIT $start, $limit GROUP BY {fields} HAVING COUNT(*) > 1
Thanks for replie.
????: NamePros.com http://www.namepros.com/showthread.php?t=668976
What about the total count for the first query?

thanks
__________________

Rapidme
(rapidshare application)
baris22 is offline   Reply With Quote
Old 07-29-2010, 11:02 AM   #4 (permalink)
New Member
Join Date: Jul 2010
Location: Boston, MA
Posts: 5
nirvdrum is an unknown quantity at this point
 




I'm not sure I follow what you're looking to do in the first query. You're selecting a single row, i.e., the count of the entire table. If you want the count for just a particular topic, it'd be:

Code:
SELECT COUNT(*) FROM file WHERE topic = '<my_topic>';
If you want to get all duplicated topics, it'd be:
????: NamePros.com http://www.namepros.com/showthread.php?t=668976

Code:
SELECT topic, COUNT(*) FROM file GROUP BY topic HAVING COUNT(*) > 1;
Note that this will not return a row of tuples consisting of the topic name and its count. Selecting just the bare count in this case wouldn't make much sense because you wouldn't have any way to tie it back to the topic.
nirvdrum is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 08:09 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger