![]() |
Converting a simple mySQL query to operate via PHP <div>I have a mysql query that I would like to execute from within PHP script. However, its not working and I believe its related to the proper usage of PHP variables. Here is the mysql query that works fine by itself: Code: SET @DaysPastMax = 15; SELECT @Date_Now:=UNIX_TIMESTAMP(); set @SecondsPastMax = @DaysPastMax * 86400; set @Date2UseMax = @Date_Now - @SecondsPastMax; DELETE all_rows.* FROM thread AS all_rows INNER JOIN ( SELECT title, dateline, min(threadid) as min_threadid FROM thread GROUP BY title HAVING count(*) >1 AND dateline BETWEEN @Date2UseMax AND @Date_Now ) AS dupe_rows ON dupe_rows.title = all_rows.title # In other words, exclude the lowest threadid of a dupe group AND dupe_rows.min_threadid < all_rows.threadid; Here is the PHP code (minus the connect string stuff which I use all the time elsewhere): <div class="bbcode_container"> PHP Code: <span style="color: #000000"><span style="color: #0000BB"> |
الساعة الآن 02:19 AM |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.2 TranZ By
Almuhajir