July 15th, 2013, 12:51 PM
Numbering query result rows
I use this code to number each number in a query result.
It works fine.
$query = "select @rownum:=@rownum+1 'rank', p.cid as id ,DATE_FORMAT(fecha, ' %W %D %M')AS bi, descripcion AS bn from festivos p, (SELECT @rownum:=0) r order by fecha;";
However when I try to adapt it to a query that includes joins
#1054 - Unknown column 'p.festivos.cid' in 'field list'
$query = "select @rownum:=@rownum+1 'rank', p.festivos.cid as id, ....etc";
Any ideas how to solve this or is there a better way to number rows?
July 15th, 2013, 01:08 PM
look very closely at this error message
Originally Posted by Carrilo
it's telling you that something is wrong with this column name
notice the two periods
which part is the table name and which part is the column name?
July 15th, 2013, 01:55 PM
OK Thanks! Seems obvious now