Mysql query question
Started by Aussiestinger, Jul 07 2006 03:38 PM
9 replies to this topic
#1
Posted 07 July 2006 - 03:38 PM
Is there any way to show the 15 newest except the very newest?
say i got
$query = "SELECT * FROM news ORDER BY ID DESC LIMIT 15";
is there anyway to make it show the latest 15 except the very latest? or it more complicated then that and would have to do with php?
say i got
$query = "SELECT * FROM news ORDER BY ID DESC LIMIT 15";
is there anyway to make it show the latest 15 except the very latest? or it more complicated then that and would have to do with php?
#2
Posted 07 July 2006 - 03:53 PM
so, you want entries 15 - 30 (missing out the lastest 15) right?
try this:
try this:
$query = "SELECT * FROM `news` ORDER BY ID DESC LIMIT 15, 30";
#3
Posted 07 July 2006 - 03:54 PM
So you want to display item 2-15 and not number 1, is that correct?
#4
Posted 07 July 2006 - 03:56 PM
QUOTE(Erik B @ Jul 7 2006, 09:53 PM) <{POST_SNAPBACK}>
So you want to display item 2-15 and not number 1, is that correct?
[/quote]
Could mean that also lol. People need to be more specific when posting
If that's the case.
#5
Posted 07 July 2006 - 04:03 PM
Often that is the case, and in case you havn't noticed, I really left this question to you since I am not too good with PHP...you would have known this by the top of your head, wheareas I would have been searching 
Aussiestinger, hopefully that was what you wanted?
Aussiestinger, hopefully that was what you wanted?
#6
Posted 07 July 2006 - 04:38 PM
Yeah the second one is what I needed, thanks heaps works perfectly.
#7
Posted 08 July 2006 - 12:04 AM
.Matt, on Jul 7 2006, 02:55 PM, said:
$query = "SELECT * FROM `news` ORDER BY ID DESC LIMIT 1, 16";
Just wanted to bring this up for future readers.
Edited by rc69, 08 July 2006 - 12:04 AM.
#8
Posted 08 July 2006 - 01:40 AM
Yeh, RC is right its 15, unless he still wants 15 shown except the first one?
#9
Posted 08 July 2006 - 02:21 AM
lol, i think doing nothing coding wise apart from help on forums for a few months is begining to show :$
Thats how i read it, he says it works so it was probably right
Good point though rc69.
Quote
unless he still wants 15 shown except the first one?
Thats how i read it, he says it works so it was probably right
#10
Posted 09 July 2006 - 12:08 AM
Thankfully my memory is good, so the decay will be slow at best. But either way, this will probably bug me till it's solved, and already knowing that, i decided to get MySQL's official opinion on the subject.
Since i read it the same way you two did, my way should be right.
[quote name='http://dev.mysql.com/doc/refman/4.1/en/select.html']The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be non-negative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15[/quote]
Either way, if it works how he wants it to, then it works, and there's nothing i'm willing to do to change that
Since i read it the same way you two did, my way should be right.
[quote name='http://dev.mysql.com/doc/refman/4.1/en/select.html']The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be non-negative integer constants (except when using prepared statements).
With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):
SELECT * FROM tbl LIMIT 5,10; # Retrieve rows 6-15[/quote]
Either way, if it works how he wants it to, then it works, and there's nothing i'm willing to do to change that
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
