what is the problem with this query? it shows null in rowno column.
SELECT @rowno:=@rowno+1 `rn`,`id`, `title`, `topic`
FROM stories,(SELECT @rownum:=0) r
WHERE newstype='2';
i run it in 'MySQL Query browser'
thanks in advance.
You have a few problems there:
@rowno
by adding set @rowno = 0
before the query.as
in @rowno:=@rowno+1 rn
.(SELECT @rownum:=0) r
is superfluous, unless you meant this to be the initialisation for @rowno
in which case you misspelt it.This should work:
SET @rowno = 0;
SELECT @rowno:=@rowno+1 as `rn`, `id`, `title`, `topic`
FROM stories
WHERE newstype='2';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With