致命错误:未捕获的PDOException:SQLSTATE [42000]:语法错误或
  访问冲突:1064您的SQL语法错误;检查
  与您的MySQL服务器版本相对应的手册
  在'AND Sold = 0 ORDER BY Date DESC,Count DESC,Price附近使用的语法
  第1026行的{path}中第14行的ASC'


查询:

select * from (numbers t inner join (select distinct n.Number
from (
  select 1 start union all select 2  union all select 3 union all
  select 4 union all select 5
) s cross join numbers n
where
  left(substring(n.Number, s.start, 2), 1) <> right(substring(n.Number, s.start, 2), 1)
  and
  n.Number like concat(
    '%', substring(n.Number, s.start, 2),
    substring(n.Number, s.start, 2),
    substring(n.Number, s.start, 2),
    substring(n.Number, s.start, 2), '%'
  )) n on n.Number = t.Number) AND Sold = 0 ORDER BY Date DESC,Count DESC,Price ASC

最佳答案

似乎您在numbers t .... and SOLD = 0之前输入了错误的几对

select *
from numbers t
inner join (select distinct n.Number
  from (
    select 1 start
    union all select 2
    union all select 3
    union all select 4
    union all select 5
) s
cross join numbers n
where
  left(substring(n.Number, s.start, 2), 1) <> right(substring(n.Number, s.start, 2), 1)
  and
  n.Number like concat(
    '%', substring(n.Number, s.start, 2),
    substring(n.Number, s.start, 2),
    substring(n.Number, s.start, 2),
    substring(n.Number, s.start, 2), '%'
  )) n on n.Number = t.Number AND Sold = 0
  ORDER BY Date DESC,Count DESC,Price ASC


无论如何,做几个嵌套的子查询检查我的建议是否真的需要

09-25 20:53