1
SELECT EM.rec_id AS rec_id,EM.employee_code, EM.employee_name, EM.designation,   EM.weekly_off_day, EM.gender, EM.payment_type, SM.shift_name, PM.plant_name, EM.status AS status,EM.settlement_no,
    SCM.section_name
    FROM employee_master AS EM 
    INNER JOIN shift_master AS SM ON EM.shift_rec_id = SM.rec_id 
    INNER JOIN section_master AS SCM ON EM.section_rec_id = SCM.rec_id 
    INNER JOIN plant_master AS PM ON EM.plant_rec_id = PM.rec_id
    ORDER BY CAST(EM.employee_code As INT) 

这是我正在使用的 sql。谢谢

4

3 回答 3

2
SELECT EM.rec_id AS rec_id,EM.employee_code, EM.employee_name, EM.designation,   EM.weekly_off_day, EM.gender, EM.payment_type, SM.shift_name, PM.plant_name, EM.status AS status,EM.settlement_no,
    SCM.section_name
    FROM employee_master AS EM 
    INNER JOIN shift_master AS SM ON EM.shift_rec_id = SM.rec_id 
    INNER JOIN section_master AS SCM ON EM.section_rec_id = SCM.rec_id 
    INNER JOIN plant_master AS PM ON EM.plant_rec_id = PM.rec_id
    ORDER BY CAST(EM.employee_code As UNSIGNED ) 

看到这个SO 线程

于 2013-08-16T11:14:45.663 回答
1

正确的语法应该是以下之一:

CAST(EM.employee_code AS UNSIGNED INTEGER)
CAST(EM.employee_code AS SIGNED INTEGER)
CAST(EM.employee_code AS UNSIGNED)
CAST(EM.employee_code AS SIGNED)

与有符号和无符号修饰符是可选的其他语言相反,在这种情况下,关键字 INTEGER 是可选的。

于 2013-08-16T11:17:53.010 回答
1

Looking at the manual for CAST, INT is not a type you can cast to. However, you can cast to SIGNED or UNSIGNED. Assuming you want the integer to be unsigned, use;

ORDER BY CAST(EM.employee_code As UNSIGNED) 
于 2013-08-16T11:15:03.407 回答