{"id":501,"date":"2012-09-07T07:43:31","date_gmt":"2012-09-07T07:43:31","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=501"},"modified":"2022-02-17T07:14:04","modified_gmt":"2022-02-17T07:14:04","slug":"manipulating-returned-results","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/mysql\/queries\/select\/manipulating-returned-results","title":{"rendered":"Manipulating Returned Results"},"content":{"rendered":"<pre>\r\n<code>\r\n$sql1 = &quot;SELECT\r\n    indexer,\r\n    user_id,\r\n    friends_id\t\tAS from_id,\t\t\t\/\/Change result name to from_id\r\n    &#39;friend&#39;\t\t\tAS type,\t\t\t\t\/\/For each record found add a result called &#39;type&#39; containing &#39;friend&#39;\r\n    todays_date\r\n  FROM friends\r\n  WHERE friends_id = $user_id&quot;;\r\n<\/code><\/pre>\n<h4>\nOutputting&nbsp;Results As A Comma Separated List (Or any character separated)<br \/>\n<\/h4>\n<pre>\r\n<code>\r\n\t$QueryString = &quot;SELECT CONCAT_WS(&#39;,&#39;,SomeColumnName0,SomeColumnName1,SomeColumnName2) \r\n\t\t\t\t\t\t\t\t\tFROM MyTable WHERE SomeColumn = 12&quot;;\r\n\t\t\t\t\t\t\t\t\/\/&quot;CONCAT_WS(&#39;,&#39;,&quot; to cause results to be comma seperated for us\r\n\t\t\t\t\r\n\t$Query1 = @mysql_query($QueryString);\r\n\t$ResultsCount = mysql_num_rows($Query1);\r\n\twhile ($result1 = @mysql_fetch_array($Query1))\r\n\t\t$ResultString .= $result1[0];\r\n<\/code><\/pre>\n<p>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>$sql1 = &quot;SELECT indexer, user_id, friends_id AS from_id, \/\/Change result name to from_id &#39;friend&#39; AS type, \/\/For each record found add a result called &#39;type&#39; containing &#39;friend&#39; todays_date FROM friends WHERE friends_id = $user_id&quot;; Outputting&nbsp;Results As A Comma Separated List (Or any character separated) $QueryString = &quot;SELECT CONCAT_WS(&#39;,&#39;,SomeColumnName0,SomeColumnName1,SomeColumnName2) FROM MyTable WHERE SomeColumn = 12&quot;; \/\/&quot;CONCAT_WS(&#39;,&#39;,&quot; [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[64],"tags":[],"class_list":["post-501","post","type-post","status-publish","format-standard","hentry","category-select"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/501","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=501"}],"version-history":[{"count":2,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/501\/revisions"}],"predecessor-version":[{"id":1808,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/501\/revisions\/1808"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}