Raised This Month: $ Target: $400
 0% 

Solved Need help with SQL Queries


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-09-2019 , 11:07   Re: Need help with SQL Queries
Reply With Quote #1

StartDate & Days are integers so you should use the following format:
PHP Code:
Startdate SQL_ReadResult(queryqcolStartdate ); 
You should use an <= condition in your query:
PHP Code:
SQL_QueryAndIgnore(sql"DELETE FROM `%s` WHERE startdate <= %i"tableStartdate
What I want to know is why you are reading all of the records in the table and then deleting 1 by one. See if this works:

PHP Code:
SQL_QueryAndIgnore(sql"DELETE FROM `%s` WHERE (Startdate + (Days * 86400)) <= %d"tableCurrDate 
__________________
Bugsy is offline
trgthe2nd
Junior Member
Join Date: Jul 2012
Location: Ohio, USA
Old 06-09-2019 , 16:16   Re: Need help with SQL Queries
Reply With Quote #2

Quote:
Originally Posted by Bugsy View Post
What I want to know is why you are reading all of the records in the table and then deleting 1 by one. See if this works:

PHP Code:
SQL_QueryAndIgnore(sql"DELETE FROM `%s` WHERE (Startdate + (Days * 86400)) <= %d"tableCurrDate 
Inexperience is the answer to that question. This works ALMOST flawlessly.
What is the syntax if I wanted to check that days is not equal to 0?
I'm using 0 as permanent rather than a whole lotta 9s.

Edit: that was a simple google
PHP Code:
SQL_QueryAndIgnore(sql"DELETE FROM `%s` WHERE (Startdate + (Days * 2)) <= %d AND Days != 0"tableCurrDate 
Thanks for the help

Last edited by trgthe2nd; 06-09-2019 at 16:30.
trgthe2nd is offline
Reply



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 -4. The time now is 17:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode