function log() { try { $bt = debug_backtrace(); $fileAndLine = ""; for ($i = 0; $i < 10; $i++) { $row = $bt[$i]; if (isset($row["file"]) && isset($row["line"])) { $fileAndLine = $row["file"] . "::" . $row["line"]; $i = 50; } } return $fileAndLine; } catch (Exception $ex) { return ""; } }
Its so simple. Just need to do below thins: |
SELECT SUBSTRING_INDEX(GROUP_CONCAT(x.id ORDER BY x.nx DESC), ',', 2) as row_name from some_table GROUP BY some_field |
It will select First two values only. |
It total value of GROUP_CONCAT is "1,2,3,4,5" Then Using SUBSTRING_INDEX would be like "1,2" |
You can use DISTINCT in GROUP_CONCAT function like SUBSTRING_INDEX(DISTINCT(GROUP_CONCAT(x.id ORDER BY x.nx DESC)), ',', 2) |