2uzhan.com
Advertisement
Now Place:2uzhan.com » retreiving a row position within a table, sorted from highest to lowest

retreiving a row position within a table, sorted from highest to lowest

MySQL @ June 12, 2005   Views:0

I was wondering how I could find out the position of a certain row within a table.

ex.

id-name-amount

1 james 40
2 harold 30
3 jason 500

how would i be able to find out that id #1 james is ranked #2 if i sort by large amount...

--------------Solutions-------------

Maybe this helps:
http://forums.mysql.com/read.php?10,26347,30241#msg-30241 maybe,
create temporary table autoindex ( id int key auto_increment, val1 varchar(12), val2 varchar(12) );
nsert into autoindex( val1, val2 ) select name, owner from pet; SELECT @row_val:=name FROM tablename WHERE id = 1;

SELECT COUNT(id) as Pos FROM tablename WHERE name < @row_val ORDER BY amount; Hi!

I am also looking for a solution for this.

I want to query for a row, and know the position of it in a specific sortion.

E.g. SELECT * FROM table WHERE id='102'

And then know the position in this query:

SELECT * FROM table ORDER BY 'title'

Please Help! SELECT d.tpl_id, d.tpl_title, d.tpl_designer, d.tpl_obeyon_default, d.tpl_type, d.tpl_account, d2.id AS position
FROM `obeyon_designs` d, (

SELECT count( * ) AS id, d3.tpl_id AS tplid
FROM `obeyon_designs` d3, `obeyon_designs` d4
WHERE d4.tpl_id <= d3.tpl_id
AND d4.tpl_obeyon_default = '0'
AND d3.tpl_obeyon_default = '0'
AND d4.tpl_type = 'private'
AND d3.tpl_type = 'private'
AND d4.tpl_account = '1'
AND d3.tpl_account = '1'
GROUP BY d3.tpl_id
) AS d2
WHERE d2.tplid = d.tpl_id
AND d.tpl_id = '2'

But does anyone know the solution when you want to sort for example on a title field?

Best Regards,
Adult SEO how to know the row position for a particular row ?
please suggest me ?

Tags:
© 2018 2uzhan.com Contact