1 marcdk Nov 06, 2006 22:35
3 balupton Nov 08, 2006 10:12
change ORDER BY `count` DESC to ORDER BY RAND()
http://www.google.com.au/search?hl=en&q=mysql+random+order&btnG=Google+Search&meta=
http://lists.evolt.org/archive/Week-of-Mon-20021230/131053.html
4 marcdk Nov 08, 2006 23:24
Thanx!
5 marcdk Nov 09, 2006 01:02
But how can I change the statement to a sql-command that lists ALL entries? This seem to limit the output to entries with at least 1 comment...
6 balupton Nov 09, 2006 01:09
what do you want the sql query to do/get?
7 marcdk Nov 09, 2006 01:17
All blog-articles of the current blog ID which are published.
8 balupton Nov 09, 2006 01:35
$sql = 'SELECT post_ID, post_title, post_urltitle '.
'FROM evo_comments, evo_posts '.
'INNER JOIN evo_postcats ON post_ID = postcat_post_ID '.
'INNER JOIN evo_categories ON postcat_cat_ID = cat_ID '.
'WHERE cat_blog_ID = \''.$params['blog'].'\' '.
'GROUP BY post_ID '.
'ORDER BY RAND() '.
'LIMIT \''.$params['limit'].'\' ;';
Edit: re-added your params and stuff
9 marcdk Nov 09, 2006 10:11
Sorry to bother you again. I am glad that you want to help me but could it be that your SQL-Statement does not work because I use 0.91?
If I try it out, it gives me an error.
And I tried to format my sql-statement in the style of yours but it does not display anything:
$sql = "SELECT ID , post_title, post_urltitle
FROM evo_posts
INNER JOIN evo_postcats ON ID = postcat_post_ID
INNER JOIN evo_categories ON postcat_cat_ID = cat_ID
WHERE (cat_blog_ID = ".$params['blog'].")
GROUP BY ID
LIMIT ".$params['limit'];
10 balupton Nov 09, 2006 12:47
but could it be that your SQL-Statement does not work because I use 0.91?
You just hit the nail on the head.
With your previous one that worked but only returned ones that had comments, get rid of the order bys besides the rand() one as they are useless becaue of the rand() and also get rid of the evo_posts.ID = evo_comments.comment_post_ID part. should do the trick.
11 edb Nov 09, 2006 13:17
12 marcdk Nov 09, 2006 13:28
Should I upgrade because of security issues?
Ok I tried this:
$sql = "SELECT ID , post_title, post_urltitle
FROM evo_posts
INNER JOIN evo_postcats ON ID = postcat_post_ID
INNER JOIN evo_categories ON postcat_cat_ID = cat_ID
WHERE cat_blog_ID = ".$params['blog']."
GROUP BY ID
LIMIT ".$params['limit'];
But then the page stays blank ...
I am getting crazy.
Any idea?
13 balupton Nov 09, 2006 13:40
Yeh, i think i would go with EdB on this one....
14 marcdk Nov 09, 2006 16:55
ok, but why does my code not work? it results in a blank page...
15 balupton Nov 09, 2006 17:06
i don't know, thats why i'm saying upgrading ;)
nobody knows?