1. ORDER BY 语句
ORDER BY 中字段必须是select 查询中的字段(示例在2中)
2. GROUP BY 语句
GROUP BY使用是必须加上你SELECT后面所查询的所有除聚合函数之外的所有字段
示例
SELECT
-- GROUP BY 示例
COUNT( resin.id ) recordNum,
resin.r_user_id,
resin.NAME userName,
resin.record_no,
resin.record_time,
MAX( resin.id ) maxid
FROM
(
SELECT
-- ORDER BY 示例
ucr.id,
ucr.dept_id,
ucr.user_id,
ucr.operator_id,
ucr.vendor_id,
ucr.r_user_id,
ucr.contract_id,
ucr.contract_no,
ucr.file_name,
ucr.file_path,
ucr.created_by,
ucr.created_at,
ucr.changed_by,
ucr.record_type,
ucr.changed_at,
ucr.record_time,
ucr.available,
ucr.start_time,
ucr.end_time,
ucr.version,
u.NAME,
u.record_no
FROM
user_contract_record ucr
LEFT JOIN r_user u ON ucr.r_user_id = u.id
WHERE
u.id IS NOT NULL
-- ORDER BY 示例
ORDER BY
ucr.id DESC
) resin
-- GROUP BY 示例
GROUP BY
resin.r_user_id,
resin.NAME,
resin.record_no,
resin.record_time
或者更改达梦数据库配置,使之兼容mysql
3. 如图mysql语句转达梦语句是 select中字段不能存在引号
4. 达梦数据库多表关联 select中尽量不要用table.* 进行查询,如果有字段冲突不会像mysql一样转义
5. 达梦数据库多表关联查询,表字段类型需要保持一致(例 int=int),如果不一致需要将数据类型强制转换成一致,比如转换为String(错误类型:-6111: 字符串转换出错)
```
CAST(ID AS VARCHAR)
```
示例: