CodeIgniter 版本:2.1.3
MySQL 版本:5.5.30
MySQL 引擎:MyISAM
询问:
$query = "INSERT INTO new_table
(
user_id,
cut_off_pay,
total_days,
rate_per_day,
rate_per_hour,
)
(
SELECT
u.id,
@cut_off_pay := (u.current_salary / 2) ,
@total_days := 10,
@rate_per_day := (@cut_off_pay / @total_days),
@rate_per_hour := (@rate_per_day / 8)
FROM attendance a
LEFT JOIN users u
ON a.user_id = u.id
WHERE a.user_id = u.id
GROUP BY a.user_id
)";
$this->db->query($query);
用户定义的变量(@cut_off_pay、@total_days 等)不起作用,它返回 0/NULL 值