我已经通过嵌套在另一个 SELECT 中,然后使用 ASC 使用标准选择查询尝试了所有现有尝试,但是由于某种原因它无法在我的 JSCharts 中加载。我的代码工作正常,减去顺序:
SELECT `$tableName`.`$patient_idField` , `$tableDataName`.`$patient_idField` , `$tableDataName`.`$resultField` , `$tableName`.`$login_idField`
FROM `$tableName`
JOIN `$tableDataName` ON `$tableName`.`$patient_idField` = `$tableDataName`.`$patient_idField`
COLLATE utf8_general_ci
WHERE `$tableName`.`$login_idField` = $usssName
ORDER BY `$tableDataName`.id DESC LIMIT 10
这是重新订购的尝试,但未能加载:
SELECT * FROM (
SELECT `$tableName`.`$patient_idField` , `$tableDataName`.`$patient_idField` , `$tableDataName`.`$resultField` , `$tableName`.`$login_idField`
FROM `$tableName`
JOIN `$tableDataName` ON `$tableName`.`$patient_idField` = `$tableDataName`.`$patient_idField`
COLLATE utf8_general_ci
WHERE `$tableName`.`$login_idField` = $usssName
ORDER BY `$tableDataName`.id DESC LIMIT 10 ) AS `$tableName` JOIN `$tableDataName` ORDER by `$tableDataName`.id ASC
在没有 PHP 的情况下更新...
SELECT userlist.patient_id, results.patient_id, results.result, userlist.login_id
FROM userlist
JOIN results ON userlist.patient_id = results.patient_id
COLLATE utf8_general_ci
WHERE userlist.login_id = ####
ORDER BY results.id DESC
LIMIT 10
现在,如果我对 ASC 执行此操作之外的任何操作,它会在patient_id
.
有效的代码,供将来参考
SELECT *
FROM (
SELECT userlist.patient_id, results.result, userlist.login_id, results.id
FROM userlist
JOIN results ON userlist.patient_id = results.patient_id
COLLATE utf8_general_ci
WHERE userlist.login_id = ####
ORDER BY results.id DESC
LIMIT 10 ) temp
ORDER BY id
它涉及删除其中一个.patient_id
on SELECT。