Skip to main content
added 5 characters in body
Source Link
choroba
  • 1.4k
  • 8
  • 11

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER (ORDER BY meta_value) AS rank,
        meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
    ORDER BY meta_value
) AS r
WHERE post_id = 18;

But I'm not sure it performs any better than your solution.

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
    ORDER BY meta_value
) AS r
WHERE post_id = 18;

But I'm not sure it performs any better than your solution.

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER (ORDER BY meta_value) AS rank,
        meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
) AS r
WHERE post_id = 18;

But I'm not sure it performs any better than your solution.

added 25 characters in body
Source Link
choroba
  • 1.4k
  • 8
  • 11

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
    ORDER BY meta_value
) AS r
WHERE post_id = 18;

But I'm not sure it performs any better than your solution.

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
) AS r
WHERE post_id = 18;

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
    ORDER BY meta_value
) AS r
WHERE post_id = 18;

But I'm not sure it performs any better than your solution.

Post Undeleted by choroba
deleted 251 characters in body
Source Link
choroba
  • 1.4k
  • 8
  • 11

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
FROM wp_postmeta
WHERE meta_key = 'points';


+------+----------+------------+---------+
| rank | meta_key | meta_value | post_idFROM |
+------+----------+------------+---------+wp_postmeta
|    1 | points   |         12 |    WHERE meta_key 23= |'points'
|    2 | points   |          2 |     ) 18AS |r
|    3 | points   |          8 |    WHERE post_id 15= |
+------+----------+------------+---------+
```18;

Mysql supports the ROW_NUMBER() function.

SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
FROM wp_postmeta
WHERE meta_key = 'points';


+------+----------+------------+---------+
| rank | meta_key | meta_value | post_id |
+------+----------+------------+---------+
|    1 | points   |         12 |      23 |
|    2 | points   |          2 |      18 |
|    3 | points   |          8 |      15 |
+------+----------+------------+---------+
```

Mysql supports the ROW_NUMBER() function.

SELECT rank
FROM (
    SELECT ROW_NUMBER() OVER () AS rank, meta_key, meta_value, post_id
    FROM wp_postmeta
    WHERE meta_key = 'points'
) AS r
WHERE post_id = 18;
Post Deleted by choroba
Source Link
choroba
  • 1.4k
  • 8
  • 11
Loading