MySQL help--looking...
 
Notifications
Clear all

MySQL help--looking for either a manual or a solution πŸ™‚

9 Posts
3 Users
0 Reactions
1,960 Views
(@mickinell)
Posts: 62
Trusted Member
Topic starter
 

I am having a little trouble figuring something out in MySQL and 90% of the online manuals I've read don't really help at all.

First of all, I have a 4.X version of MySQL--I think 4.1.something or other.

Here's what I am trying to do:  I want to limit a database query to only include stories that have not been updated for "X" amount of time (most likely 6 months and beyond).  However, every suggestion I have tried from manuals gives me a syntax error.  Boo.

The current code looks like this:

$result = dbquery("SELECT story.title as storytitle, story.uid, story.sid, story.catid, story.updated, story.completed, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX." fanfiction_stories as story, "._AUTHORTABLE.") WHERE story.completed = '0' AND story.uid = "._UIDFIELD." ORDER BY story.updated;");

And I want to limit it to only include stories where story.updated is 6 months or more older than the current system time.

If you'd like to see what specifically I am trying to do, here's the info:
http://www.mickiclark.com/efiction33/
login: efiction, password: test

Select "inactive fictions" from the admin menu or use this link to go straight there:  http://www.mickiclark.com/efiction33/admin.php?action=inactive

So...if anyone knows of a MySQL manual that doesn't expect you to already know what you're doing, or knows how to modify my code to do what I'm looking for, I would be eternally grateful.  πŸ™‚


URL to your eFiction:  http://www.mickiclark.com/efiction33
Version of eFiction:  3.3.1
Have you bridged eFiction, if so with what?:  SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14

 
Posted : 27/02/2008 4:09 pm
 Elle
(@jenny)
Posts: 594
Honorable Member
 

I removed the brackets and the space...see if it works?

$result = dbquery("SELECT story.title as storytitle, story.uid, story.sid, story.catid, story.updated, story.completed, "._PENNAMEFIELD." as penname FROM ".TABLEPREFIX."fanfiction_stories as story, "._AUTHORTABLE." WHERE story.completed = '0' AND story.uid = "._UIDFIELD." ORDER BY story.updated;");

archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 27/02/2008 4:17 pm
(@mickinell)
Posts: 62
Trusted Member
Topic starter
 

I think you misunderstood me.  The existing code works, I'm just trying to figure out how to add the time limit to it.


URL to your eFiction:  http://www.mickiclark.com/efiction33
Version of eFiction:  3.3.1
Have you bridged eFiction, if so with what?:  SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14

 
Posted : 27/02/2008 4:19 pm
 Elle
(@jenny)
Posts: 594
Honorable Member
 

Oh! Sorry.

AND (DATE(`updated`) BETWEEN DATE(SUBDATE(CURDATE(), INTERVAL 6 MONTH)) AND CURDATE())

That's something I use on another script.


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 27/02/2008 4:22 pm
(@mickinell)
Posts: 62
Trusted Member
Topic starter
 

THANK YOU!!!!

I modified it slightly to fit my purposes, but that worked much better than what I was trying to do with the timestamp!

AND (DATE(`updated`) <= DATE(SUBDATE(CURDATE(), INTERVAL 6 MONTH)))

URL to your eFiction:  http://www.mickiclark.com/efiction33
Version of eFiction:  3.3.1
Have you bridged eFiction, if so with what?:  SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14

 
Posted : 27/02/2008 5:00 pm
 Elle
(@jenny)
Posts: 594
Honorable Member
 

Awesome, glad I could be of some help. πŸ˜€


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 27/02/2008 5:08 pm
(@tammy)
Posts: 2577
Member Moderator
 

Um.  Take the recent browse panel and change > to <.


 
Posted : 27/02/2008 5:24 pm
(@mickinell)
Posts: 62
Trusted Member
Topic starter
 

That would have worked if we only wanted a list, but we wanted something similar to the queue.  Our inactive.php is a modification of submitted.php.


URL to your eFiction:  http://www.mickiclark.com/efiction33
Version of eFiction:  3.3.1
Have you bridged eFiction, if so with what?:  SMF
Version of PHP:
Version of MySQL: MySQL 4.1.14

 
Posted : 27/02/2008 8:16 pm
(@tammy)
Posts: 2577
Member Moderator
 

The query is the same for both I believe.


 
Posted : 27/02/2008 10:46 pm
Share: