![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Industry Role:
Join Date: Feb 2005
Location: Los Angeles
Posts: 1,531
|
A little MySQL help...
I have query that gets data from the database, processes that data, then deletes the original data, but I need help with the query to "delete only the data we just SELECTED".
Currently I have this Code:
// Get data using query SELECT bd_action,bd_target,SUM(bd_count) AS bd_count,bd_data FROM bd_action GROUP BY CONCAT(bd_data,bd_action,bd_target) // Delete the data (actually just delete everything) DELETE FROM bd_action Modified but not working: Code:
// Get data using query LIMIT 10000 SELECT bd_action,bd_target,SUM(bd_count) AS bd_count,bd_data FROM bd_action GROUP BY CONCAT(bd_data,bd_action,bd_target) LIMIT 10000 // ?? Delete the data that I just got (delete ONLY the stuff I just got in the previous query) DELETE FROM bd_action WHERE (SELECT bd_action,bd_target,SUM(bd_count) AS bd_count,bd_data FROM bd_action GROUP BY CONCAT(bd_data,bd_action,bd_target) LIMIT 10000) Thoughts?
__________________
www.gimmiegirlproductions.com |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
So Fucking Fossilized
Industry Role:
Join Date: Sep 2011
Posts: 1,432
|
Set an ID on the data field, then when you loop over that data, at the end send the delete query with WHERE data_id = $query->data_id
Then when it's done with that row, it'll delete it and move on to the next one. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: May 2008
Posts: 3,406
|
DELETE FROM bd_action WHERE (SELECT bd_action,bd_target,SUM(bd_count) AS bd_count,bd_data FROM bd_action GROUP BY CONCAT(bd_data,bd_action,bd_target LIMIT 10000) )
I would try that? Also, copy the table to a new table, and try running it against that one first. Otherwise, you can do it with php |
![]() |
![]() ![]() ![]() ![]() ![]() |