Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 10-23-2009, 08:17 AM
newmomsforum newmomsforum is offline
 
Join Date: Mar 2006
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default SQL to Delete Duplicate posts in VB 3.8

Hi Guys

I've been trying to use the following SQL command to delete duplicate posts in a single thread:

Code:
SELECT bad_rows. * FROM post AS bad_rows
INNER JOIN (
SELECT threadid, dateline, username, userid, MIN( postid ) AS min_postid FROM post
GROUP BY threadid, dateline, userid
HAVING count( * ) >1
) AS good_rows ON good_rows.threadid = bad_rows.threadid
AND good_rows.dateline = bad_rows.dateline
AND good_rows.userid = bad_rows.userid
AND good_rows.min_postid <> bad_rows.postid
The SQL query was originally posted by Wayne here although this was for an earlier version of VB:

http://www.vbulletin.com/forum/showthread.php?t=285501

Unfortuantly, when I run this query on version 3.8 of my boards I get the following error message:

Quote:
An error occurred while attempting to execute your query. The following information was returned.
error number: 1064
error desc: 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 'SELECT threadid, dateline, username, userid, MIN( postid ) AS m
Does anyone have any ideas what will work on my boards

Many many thanks in advance

Regards

Mark
Reply With Quote
  #2  
Old 10-25-2009, 12:32 AM
newmomsforum newmomsforum is offline
 
Join Date: Mar 2006
Posts: 41
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry to bump guys but my forums are looking really messy after a failed import.

Any ideas or suggestions greatly appreciated.

Cheers

Mark
Reply With Quote
  #3  
Old 10-31-2009, 06:01 PM
gmerin gmerin is offline
 
Join Date: Dec 2008
Posts: 78
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just a suggestion: re-type the query making sure you have no spurious characters in the text and no extra whitespace at the end of the lines (which sometimes happens when you cut & paste) because when i run the query from your post against my dbms from the sql commandline, I don't get any sql errors:

[SQL] SELECT bad_rows. * FROM post AS bad_rows
INNER JOIN (
SELECT threadid, dateline, username, userid, MIN( postid ) AS min_postid FROM post
GROUP BY threadid, dateline, userid
HAVING count( * ) >1
) AS good_rows ON good_rows.threadid = bad_rows.threadid
AND good_rows.dateline = bad_rows.dateline
AND good_rows.userid = bad_rows.userid
AND good_rows.min_postid <> bad_rows.postid

Affected rows: 0
Time: 0.098ms

not saying the sql is correct for the task you want to accomplish, just that it's not throwing errors for me.
Reply With Quote
  #4  
Old 11-17-2010, 06:38 PM
FlyingBurrito4 FlyingBurrito4 is offline
 
Join Date: Aug 2010
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where would I add this SQL?
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 05:45 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04692 seconds
  • Memory Usage 2,184KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete