Fitness.com
Advertisement
Go Back   Sports Forum > Community > The Pub

The Pub

Grab a beer, sit back and relax.


» Current Poll
Best 5 club teams in history of Football:
Liverpool 1977-1978 - 100.00%
1 Vote
Real Madrid 1956-1960 - 0%
0 Votes
Juventus 1985 - 0%
0 Votes
Milan 1989-1990 - 100.00%
1 Vote
Ajax 1971-1973 - 0%
0 Votes
Santos 1962-1963 - 0%
0 Votes
Torinho 1940's - 100.00%
1 Vote
Ajax 1995 - 0%
0 Votes
Flamengo 1981 - 100.00%
1 Vote
Benfica 1961-1962 - 100.00%
1 Vote
Total Votes: 1
You may not vote on this poll.
» Stats
Members: 103,035
Threads: 85,013
Posts: 1,031,286
Top Poster: Karky (9,532)
Welcome to our newest member, Mr.M
If you register for free, you will be able to post threads, vote on polls and lots more. If you have problems with the registration or logging in, please contact the administrator.

Reply
 
LinkBack Thread Tools Display Modes
Old 09-22-2007, 03:29 PM   Simple MySQL query Post #1
Registered User
 
Join Date: Jul 2007
Posts: 0
Rep Power: 0
retired_musiclova31 is an unknown quantity at this point
Default Simple MySQL query

Trying to only show news items posted in the last 14 days. got no idea why it's not working - no data returned despite there being two rows in the dataset that qualify...

<pre class="ip-ubbcode-code-pre">SELECT news_title, news_body, news_datestamp, phpbb3_users.username AS news_author_name, news_authorFROM tq_news, phpbb3_usersWHERE phpbb3_users.user_id = tq_news.news_author AND DATEDIFF(NOW( ), news_datestamp) &lt; 14ORDER BY news_id DESC</pre>

any ideas?
retired_musiclova31 is offline   Reply With Quote
Old 09-22-2007, 03:36 PM   Simple MySQL query Post #2
Newb
 
Join Date: Sep 2007
Posts: 0
Rep Power: 0
retired_gulkis is an unknown quantity at this point
Default

DATEDIFF is always a bit of a **** for me. what happens if you use TO_DAYS(...) - TO_DAYS(..) in place of it? at least to localise the problem.
retired_gulkis is offline   Reply With Quote
Old 09-22-2007, 03:50 PM   Simple MySQL query Post #3
Newb
 
Join Date: Sep 2007
Posts: 0
Rep Power: 0
retired_jerilyn is an unknown quantity at this point
Default

Should avoid using DateDiff where possible, it's heavy on the processing.

Could you use:

...AND news_datestamp &gt;= getdate()-14

?
retired_jerilyn is offline   Reply With Quote
Old 09-22-2007, 03:50 PM   Simple MySQL query Post #4
Registered User
 
Join Date: Jul 2007
Posts: 0
Rep Power: 0
retired_musiclova31 is an unknown quantity at this point
Default

how would i structure that?

never used it before.
retired_musiclova31 is offline   Reply With Quote
Old 09-22-2007, 03:51 PM   Simple MySQL query Post #5
Registered User
 
Join Date: Jul 2007
Posts: 0
Rep Power: 0
retired_musiclova31 is an unknown quantity at this point
Default

that's not valid syntax eddy
retired_musiclova31 is offline   Reply With Quote
Old 09-22-2007, 03:55 PM   Simple MySQL query Post #6
Registered User
 
Join Date: Sep 2007
Posts: 0
Rep Power: 0
retired_bigsean999 is an unknown quantity at this point
Default

move the equals back one place!
retired_bigsean999 is offline   Reply With Quote
Old 09-22-2007, 03:55 PM   Simple MySQL query Post #7
Newb
 
Join Date: Sep 2007
Posts: 0
Rep Power: 0
retired_jerilyn is an unknown quantity at this point
Default

That'll be because its MySQL, missed that....

Does

WHERE DATE_SUB(CURDATE(),INTERVAL 14 DAY) &lt;= news_datestamp

work?
retired_jerilyn is offline   Reply With Quote
Old 09-22-2007, 03:56 PM   Simple MySQL query Post #8
Newb
 
Join Date: Sep 2007
Posts: 0
Rep Power: 0
retired_gulkis is an unknown quantity at this point
Default

(TO_DAYS(NOW()) - TO_DAYS(news_datestamp)) &lt; 14

just instead of the DATEDIFF bit. a bit of googling says DATEDIFF is apparently a bit dodgy until version 4.1.15.
retired_gulkis is offline   Reply With Quote
Old 09-22-2007, 03:58 PM   Simple MySQL query Post #9
Registered User
 
Join Date: Jul 2007
Posts: 0
Rep Power: 0
retired_musiclova31 is an unknown quantity at this point
Default

using tim's to_days... still showing no data

changed the 14 to 1000 and still says no data. there is definitely data in the db.
retired_musiclova31 is offline   Reply With Quote
Old 09-22-2007, 03:59 PM   Simple MySQL query Post #10
Registered User
 
Join Date: Jul 2007
Posts: 0
Rep Power: 0
retired_musiclova31 is an unknown quantity at this point
Default

Quote:
Originally posted by EddyB:
That'll be because its MySQL, missed that....

Does

WHERE DATE_SUB(CURDATE(),INTERVAL 14 DAY) &lt;= news_datestamp

work?
no. invalid syntax apparently
retired_musiclova31 is offline   Reply With Quote
Reply

Go Back   Sports Forum > Community > The Pub

Bookmarks

Thread Tools
Display Modes


Similar threads to Simple MySQL query
Thread Thread Starter Forum Replies Last Post
simple question needing a simple answer
simple question needing a simple answer: editors forum
matthew43 Scout Report 1 02-18-2008 11:52 AM
Simple answer to a simple (seemingly) question
Simple answer to a simple (seemingly) question: Where exactly do the graphics (logos, ect) go? ...
SlayerX Skinning Hideout 0 01-22-2008 02:42 AM
Simple Guide To Changing Commentry (More Simple And Specific Than Other Post :)
Simple Guide To Changing Commentry (More Simple And Specific Than Other Post :): Ive know how to find the match events folder but...
Nipersoft Skinning Hideout 0 11-03-2007 06:04 PM
personal development: php and mysql - anyone know much about these?
personal development: php and mysql - anyone know much about these?: I am pretty much useless at the moment, 2nd year...
Samamatara The Pub 3 09-07-2007 12:14 AM
Kit Query
Kit Query: Hey guys, first post on gere in a long time,...
larsson is god Skinning Hideout 1 11-15-2005 08:51 PM

More threads of Scatter
Thread Date Forum Replies Last Post
Teh nu *fishal* Hooooon-day A-League Mark Free point Oh Fred. Sponsored by Bling FC, now with Juninho goodness.
Teh nu *fishal* Hooooon-day A-League Mark Free point Oh Fred. Sponsored by Bling FC, now with Juninho goodness.: when did jardel sign for newcastle? :D ...
08-23-2007 The Pub 40 11-19-2007 09:39 AM
Yet another study suggesting piracy doesn't affect sales, and may actually INCREASE them...
Yet another study suggesting piracy doesn't affect sales, and may actually INCREASE them...: Interesting...
11-14-2007 The Pub 64 11-15-2007 06:13 PM
Mates, need some GPS buying advice
Mates, need some GPS buying advice: Thinking of buying the missus a GPS for...
11-12-2007 The Pub 10 11-13-2007 04:53 PM
Patrice Evra...
Patrice Evra...: ...is God. This has been a community service...
10-14-2007 The Pub 75 10-15-2007 12:27 PM
Simple MySQL query
Simple MySQL query: Trying to only show news items posted in the last...
09-22-2007 The Pub 18 09-22-2007 05:01 PM

Other threads in forum The Pub
Thread Date Thread Starter Replies Last Post
List of manager changes?
List of manager changes?: Hi, I am looking for a list of all manager...
12-01-2007 Chris Bagnall 14 12-02-2007 08:17 PM
Terminator 4
Terminator 4: so they have found an actor to play the future...
11-22-2007 sunkilmoon 12 11-22-2007 04:32 PM
Later I plan to smoke an entire salmon
Later I plan to smoke an entire salmon: And I'm really not sure how to. Any cigarette or...
11-19-2007 ceefax the cat 54 11-20-2007 05:01 PM
Small I-Net problem. Every website works for me except 1. Please help.
Small I-Net problem. Every website works for me except 1. Please help.: Can't seem to get a website working. I know it...
11-14-2007 lovenkrands01 4 11-14-2007 10:44 AM
Charlie Jade
Charlie Jade: Never seen a thread but it gets it's UK Premiere...
10-26-2007 Gary Toner 3 10-26-2007 12:59 AM

» Online Users: 20
0 members and 20 guests
No Members online
Most users ever online was 2,128, 07-21-2008 at 08:27 PM.

All times are GMT +1. The time now is 01:27 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Fitness.com | Weight Loss | Training & Fitness | BodyBuilding | Chinese | Spanish | French | Germany | Italian | Friend Codes |
You are viewing Simple MySQL query.