{"id":271,"date":"2008-12-03T19:59:14","date_gmt":"2008-12-03T17:59:14","guid":{"rendered":"http:\/\/code.openark.org\/blog\/?p=271"},"modified":"2008-12-13T06:32:56","modified_gmt":"2008-12-13T04:32:56","slug":"dynamic-sequencing-with-a-single-query","status":"publish","type":"post","link":"https:\/\/code.openark.org\/blog\/mysql\/dynamic-sequencing-with-a-single-query","title":{"rendered":"Dynamic sequencing with a single query"},"content":{"rendered":"<p>It is a known trick to use a session variables for dynamically counting\/sequencing rows. The way to go is to SET a variable to zero, then use arithmetic within assignment to increment its value for each row in the SELECTed rows.<\/p>\n<p>For example, the following query lists the top 10 populated countries, using <a title=\"MySQL's world database setup\" href=\"http:\/\/dev.mysql.com\/doc\/world-setup\/en\/world-setup.html\">MySQL&#8217;s world database<\/a>:<\/p>\n<blockquote>\n<pre>SELECT Code, Name, Population\r\nFROM Country ORDER BY Population DESC LIMIT 10;\r\n\r\n+------+--------------------+------------+\r\n| Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+--------------------+------------+\r\n| CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n| IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n| USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n| IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n| BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n| PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n| RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n| BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n| JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n| NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+--------------------+------------+<\/pre>\n<\/blockquote>\n<p>The results do not provide any sequence number. Nor does the table have an AUTO_INCREMENT or otherwise unique row number. If I were to rate the countries by population, the common trick is:<\/p>\n<blockquote>\n<pre>SET @rank := 0;\r\nSELECT\r\n  @rank := @rank+1 AS rank,\r\n  Code, Name, Population\r\nFROM Country ORDER BY Population DESC LIMIT 10;\r\n\r\n+------+------+--------------------+------------+\r\n| rank | Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+------+--------------------+------------+\r\n|\u00a0\u00a0\u00a0 1 | CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n|\u00a0\u00a0\u00a0 2 | IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n|\u00a0\u00a0\u00a0 3 | USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n|\u00a0\u00a0\u00a0 4 | IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n|\u00a0\u00a0\u00a0 5 | BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n|\u00a0\u00a0\u00a0 6 | PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n|\u00a0\u00a0\u00a0 7 | RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n|\u00a0\u00a0\u00a0 8 | BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n|\u00a0\u00a0\u00a0 9 | JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n|\u00a0\u00a0 10 | NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+------+--------------------+------------+<\/pre>\n<\/blockquote>\n<p>The first query sets the @rank to zero, so that it is not NULL (since no arithmetic can be done with NULL).\u00a0 The second query relies on its success.<\/p>\n<p><strong>Can the same be achieved with one query only? <\/strong>That&#8217;s more of a problem.<!--more--> To try this out, I <em>log out<\/em> (important, otherwise @rank still has its previous value) from my client, log in again, and try the following:<\/p>\n<blockquote>\n<pre>SELECT\r\n  @rank := IFNULL(@rank,0)+1 AS rank,\r\n  Code, Name, Population\r\nFROM Country ORDER BY Population DESC LIMIT 10;\r\n\r\n+------+------+--------------------+------------+\r\n| rank | Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+------+--------------------+------------+\r\n|\u00a0\u00a0\u00a0 1 | CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n|\u00a0\u00a0\u00a0 1 | IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n|\u00a0\u00a0\u00a0 1 | USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n|\u00a0\u00a0\u00a0 1 | IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n|\u00a0\u00a0\u00a0 1 | BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n|\u00a0\u00a0\u00a0 1 | PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n|\u00a0\u00a0\u00a0 1 | RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n|\u00a0\u00a0\u00a0 1 | BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n|\u00a0\u00a0\u00a0 1 | JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n|\u00a0\u00a0\u00a0 1 | NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+------+--------------------+------------+<\/pre>\n<\/blockquote>\n<p>Ooops. When a session variable is NULL, it only gets assigned <em>after the query completes<\/em>, instead of per row. (For fun, try running the above query again in the same session, and see what values you get for @rank).<\/p>\n<p>I do not know the reason for this behavior. I don&#8217;t even know if it&#8217;s intended. But I do want to make a workaround. So I try by using various techniques:<\/p>\n<blockquote>\n<pre>SELECT\r\n  @rank := CASE @rank WHEN NULL THEN 0 ELSE @rank + 1 END AS rank,\r\n  Code, Name, Population\r\nFROM Country ORDER BY Population DESC LIMIT 10;\r\n\r\n+------+------+--------------------+------------+\r\n| rank | Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+------+--------------------+------------+\r\n| NULL | CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n| NULL | IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n| NULL | USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n| NULL | IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n| NULL | BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n| NULL | PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n| NULL | RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n| NULL | BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n| NULL | JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n| NULL | NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+------+--------------------+------------+<\/pre>\n<\/blockquote>\n<p>Well, that wouldn&#8217;t work since NULL compared with NULL returns NULL, right? Let&#8217;s try another:<\/p>\n<blockquote>\n<pre>SELECT\r\n  @rank := CASE WHEN @rank IS NULL THEN 0 ELSE @rank + 1 END AS rank,\r\n  Code, Name, Population\r\nFROM Country ORDER BY Population DESC LIMIT 10;\r\n\r\n+------+------+--------------------+------------+\r\n| rank | Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+------+--------------------+------------+\r\n|\u00a0\u00a0\u00a0 0 | CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n|\u00a0\u00a0\u00a0 0 | IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n|\u00a0\u00a0\u00a0 0 | USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n|\u00a0\u00a0\u00a0 0 | IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n|\u00a0\u00a0\u00a0 0 | BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n|\u00a0\u00a0\u00a0 0 | PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n|\u00a0\u00a0\u00a0 0 | RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n|\u00a0\u00a0\u00a0 0 | BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n|\u00a0\u00a0\u00a0 0 | JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n|\u00a0\u00a0\u00a0 0 | NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+------+--------------------+------------+<\/pre>\n<\/blockquote>\n<p>We can go on like this (and I did) trying to force the session variable into being set to 0 after the first row. Once can try nested assignment, selecting from DUAL, using IF, NULLIF and more. Still, MySQL will only set the variable, if it&#8217;s NULL, <em>after<\/em> the query completes. A solution is to force the variable to zero before the query begins. I will use a UNION ALL, in which the first part sets the @rank, and the second performs the query. Since its a UNION, I need to have the same number of columns in both parts. Moreover, since I&#8217;m ORDERing by Population, a column named `Population` must exist in the first part. This leads to the following query:<\/p>\n<blockquote>\n<pre>SELECT NULL AS rank, NULL AS Code, NULL AS Name, NULL AS Population\r\n  FROM DUAL WHERE (@rank := 0)&lt;0\r\nUNION ALL\r\nSELECT @rank := @rank + 1 AS rank, Code, Name, Population\r\n  FROM Country ORDER BY Population DESC LIMIT 10\r\n\r\n+------+------+--------------------+------------+\r\n| rank | Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+------+--------------------+------------+\r\n|\u00a0\u00a0 94 | CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n|\u00a0\u00a0 72 | IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n|\u00a0 229 | USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n|\u00a0\u00a0 71 | IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n|\u00a0\u00a0 29 | BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n|\u00a0 152 | PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n|\u00a0 226 | RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n|\u00a0\u00a0 19 | BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n|\u00a0\u00a0 82 | JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n|\u00a0 146 | NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+------+--------------------+------------+<\/pre>\n<p>The first query in the UNION should not return any rows, hence the impossible (@rank := 0)&lt;0 condition.<\/p><\/blockquote>\n<p>Well, the rank has numbers all right, but what kind of numbers are these? Apparently the ranking took place <em>before<\/em> the ORDER BY. Not giving up, we try one more time:<\/p>\n<blockquote>\n<pre>SELECT NULL AS rank, NULL AS Code, NULL AS Name, NULL AS Population\r\n  FROM DUAL WHERE (@rank := 0)&lt;0\r\nUNION ALL\r\nSELECT @rank := @rank + 1 AS rank, Code, Name, Population\r\n  FROM (SELECT Code, Name, Population\r\n    FROM Country ORDER BY Population DESC LIMIT 10) AS c\r\n\r\n+------+------+--------------------+------------+\r\n| rank | Code | Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | Population |\r\n+------+------+--------------------+------------+\r\n|\u00a0\u00a0\u00a0 1 | CHN\u00a0 | China\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1277558000 |\r\n|\u00a0\u00a0\u00a0 2 | IND\u00a0 | India\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 | 1013662000 |\r\n|\u00a0\u00a0\u00a0 3 | USA\u00a0 | United States\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 278357000 |\r\n|\u00a0\u00a0\u00a0 4 | IDN\u00a0 | Indonesia\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 212107000 |\r\n|\u00a0\u00a0\u00a0 5 | BRA\u00a0 | Brazil\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 170115000 |\r\n|\u00a0\u00a0\u00a0 6 | PAK\u00a0 | Pakistan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 156483000 |\r\n|\u00a0\u00a0\u00a0 7 | RUS\u00a0 | Russian Federation |\u00a0 146934000 |\r\n|\u00a0\u00a0\u00a0 8 | BGD\u00a0 | Bangladesh\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 129155000 |\r\n|\u00a0\u00a0\u00a0 9 | JPN\u00a0 | Japan\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 126714000 |\r\n|\u00a0\u00a0 10 | NGA\u00a0 | Nigeria\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 |\u00a0 111506000 |\r\n+------+------+--------------------+------------+<\/pre>\n<\/blockquote>\n<p>Now we&#8217;ve got it!<\/p>\n<p>The question arises: why go through all this when a simple two-queries solution is available?<\/p>\n<p>First, as a MySQL excercise, I find this an interesting problem. Second, it just may be possible you&#8217;ll be bound with one single query. For example, reporting tools may only allow for one query per report table. As another example, you may not have a sophisticated connection pool, and you are bound for sending one query per connection, hence unable to store session variables in between.<\/p>\n<p>If you know of other solutions, hopefully simpler ones, please comment below!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is a known trick to use a session variable for dynamically counting\/sequencing rows. The way to go is to SET a variable to zero, then use arithmetic within assignment to increment its value for each row in the SELECTed rows.<\/p>\n<p>But can it be achieved with one query only? That&#8217;s more of a problem&#8230; I&#8217;ll provide such a solution, albeit not a pretty one.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[5],"tags":[21,20],"class_list":["post-271","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-sql","tag-syntax"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2bZZp-4n","_links":{"self":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/comments?post=271"}],"version-history":[{"count":14,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"predecessor-version":[{"id":284,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/posts\/271\/revisions\/284"}],"wp:attachment":[{"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code.openark.org\/blog\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}