我如何订购此查询?
当我尝试将 orderby 添加到 sql 查询时遇到问题。
原始查询是:
SELECT SQL_CALC_FOUND_ROWS `client_data`.userid,users.username as name,
users.guid, `client_data`.fname,
`client_data`.country,`client_data`.city,
DATE_FORMAT(`client_data`.startdate, '%d-%m-%Y') as startdate,
DATE_FORMAT(`client_data`.enddate, '%d-%m-%Y') as enddate, `client_data`.registerdate,
`client_data`.agents, `client_data`.phone1, `client_data`.phone2, `client_data`.email,
`client_data`.officeName, `client_data`.address,
users.password, `client_data`.private,
users.`machineid`
FROM `client_data`
join users
on (users.iid=`client_data`.userid)
GROUP BY `client_data`.userid
LIMIT 0, 25
我添加“ ORDER BY 'client_data'.userid” 进行查询,然后它不起作用。新查询:
SELECT SQL_CALC_FOUND_ROWS `client_data`.userid,users.username as name, users.guid,
`client_data`.fname, `client_data`.country,`client_data`.city,
DATE_FORMAT(`client_data`.startdate, '%d-%m-%Y') as startdate,
DATE_FORMAT(`client_data`.enddate, '%d-%m-%Y') as enddate,
`client_data`.registerdate, `client_data`.agents, `client_data`.phone1, `client_data`.phone2,
`client_data`.email, `client_data`.officeName,
`client_data`.address, users.password,
`client_data`.private, users.`machineid`
FROM `client_data`
join users
on (users.iid=`client_data`.userid)
GROUP BY `client_data`.userid
LIMIT 0, 25
ORDER BY 'client_data'.userid
我得到这个错误代码:
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 5 行的“ORDER BY 'client_data'.userid' 附近使用正确的语法运行失败
如何添加订单