meekro

Query MySQL alphanumeric w/ Limit using MeekroDB

允我心安 提交于 2019-12-25 12:47:41
问题 I'm trying to sort by certain alphanumeric range 1-3 & A-B for first 15 matches, but am getting nothing in output. Using MeekroDB. Not sure how to translate what I have here to their method. $results = DB::query("SELECT substr(theme, 1, 1) as Alphabet FROM gallery ORDER BY (CASE theme WHEN '1%' THEN 1 WHEN '2%' THEN 2 WHEN '3%' THEN 3 WHEN 'A%' THEN 4 WHEN 'B%' THEN 5 ELSE -1 END) LIMIT 15"); $x = 0 foreach ($results as $row) { $x++; if ($x == 1) { // first in query $t1 = $row['theme']; $d1 =