mysql query
Moderator: General Moderators
mysql query
I have the following table:
posts | replies
1 | 5
2 | 2
3 | 0
4 | 5
5 | 3
6 | 4
7 | 8
8 | 3
9 | 0
10 | 1
I would like to order the last 5 posts order by replies DESC
posts| replies
7 | 8
6 | 4
8 | 3
10 | 1
9 | 0
Could you provide my the query?
...
posts | replies
1 | 5
2 | 2
3 | 0
4 | 5
5 | 3
6 | 4
7 | 8
8 | 3
9 | 0
10 | 1
I would like to order the last 5 posts order by replies DESC
posts| replies
7 | 8
6 | 4
8 | 3
10 | 1
9 | 0
Could you provide my the query?
...
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Wow, you're so close to being there.. what's stopping you from completing the query?
Anywho,
Anywho,
Code: Select all
SELECT posts FROM tablename ORDER BY replies DESCCode: Select all
SELECT posts FROM tablename ORDER BY replies DESC-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Oh, I'm sorry, I didn't notice that part.
Code: Select all
SELECT posts FROM tablename ORDER BY replies DESC LIMIT 0,5It seems I have to execut a subquery but I am not receiving any echo... 
What is wrong with the code above?
What is wrong with the code above?
Code: Select all
$Table='daTable';
$discussions=5;
$fields='posts,replies';
$select="SELECT * FROM '.$Table.' ORDER BY post DESC LIMIT '.$discussions.'";
$cols=mysql_fetch_row(mysql_query('SELECT '.$fields.' FROM ('.$select.') ORDER BY replies DESC'));1. First part I found the error
instead
2. Second error
But still not running well the query. Only showing me one result instead 5
Removing () it will not show any result...
Code: Select all
$select='SELECT * FROM '.$Table.' ORDER BY post DESC LIMIT '.$discussions.'';Code: Select all
$select="SELECT * FROM '.$Table.' ORDER BY post DESC LIMIT '.$discussions.'";2. Second error
Code: Select all
$cols=mysql_fetch_row(mysql_query('SELECT '.$fields.' FROM ('.$select.') dt ORDER BY replies DESC'));But still not running well the query. Only showing me one result instead 5
Removing () it will not show any result...