What is the best way to delete when a join is involved?
Thanks!
SELECT
u.uID,
s.searchDate,
u.last,
s.keyword,
s.alerts,
s.lastAlert,
s.clicks,
s.lastClick,
s.timeStamp
FROM users u
INNER
JOIN searches s
ON u.uID = s.author
WHERE
(DATE_SUB(CURDATE(),INTERVAL 1825 DAY) > u.last) and clicks < 4
ORDER BY last
limit 1000;
the SQL to do deletions using a join actually varies a great deal from one database system to another
here at sitepoint, we have a databases forum and a mysql forum, so since you did not post in the mysql forum, could you tell us which database system you’re running
DELETE searches
FROM users
INNER
JOIN searches
ON searches.author = users.uID
AND searches.clicks < 4
WHERE users.last < CURRENT_DATE - INTERVAL 1825 DAY