これは私のクエリです:
$query = "UPDATE ".$SupportTicketsTable." a
LEFT JOIN ".$SupportUserTable." b
ON b.id=a.operator_id
SET
a.title=? ,
a.priority=?,
b.solved_tickets= CASE WHEN (a.ticket_status='0' AND b.solved_tickets>=1) THEN (b.solved_tickets-1) ELSE b.solved_tickets END ,
b.assigned_tickets= CASE WHEN (a.ticket_status='1' AND b.assigned_tickets >=1) THEN (b.assigned_tickets-1) ELSE b.assigned_tickets END ,
a.ticket_status=?,
a.operator_id='0'
WHERE a.enc_id=?";
内のすべてのフィールドを変更できますがa
、テーブル内のフィールドは変更できず、b
理由がわかりません。これらは私のテーブルb.id
です:a.operator_id
CREATE TABLE IF NOT EXISTS `razorphyn_support_list_tickets` (
`id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT,
`enc_id` CHAR(87),
`ref_id` VARCHAR(18),
`department_id` BIGINT(11) UNSIGNED NOT NULL,
`operator_id` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0,
`user_id` BIGINT(11) UNSIGNED NOT NULL,
`title` VARCHAR(255) NOT NULL,
`priority` INT(2) UNSIGNED NOT NULL,
`website` VARCHAR(200) NOT NULL,
`contype` ENUM('0','1','2','3','4','5') NOT NULL DEFAULT '0',
`ftp_user` VARCHAR(60) NOT NULL,
`ftp_password` VARCHAR(60) NOT NULL,
`created_time` DATETIME NOT NULL,
`last_reply` DATETIME NOT NULL,
`ticket_status` ENUM('0','1','2','3') NOT NULL DEFAULT '2',
`operator_rate` DECIMAL(4,2) UNSIGNED,
PRIMARY KEY (`id`),
UNIQUE KEY (`user_id`,`title`),
INDEX (`enc_id`,`department_id`,`operator_id`,`user_id`,`ticket_status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=20;
CREATE TABLE IF NOT EXISTS `razorphyn_support_users` (
`id` BIGINT(15) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL,
`mail` VARCHAR(50) NOT NULL,
`password` VARCHAR(200) NOT NULL,
`reg_key` VARCHAR(260) ,
`tmp_password` VARCHAR(87) ,
`ip_address` VARCHAR(50) NOT NULL,
`status` ENUM('0','1','2','3','4') NOT NULL DEFAULT '3',
`holiday` ENUM('0','1') NOT NULL DEFAULT '0',
`mail_alert` ENUM('no','yes') NOT NULL DEFAULT 'yes',
`assigned_tickets` INT(5) UNSIGNED NOT NULL DEFAULT 0,
`solved_tickets` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0,
`number_rating` BIGINT(6) UNSIGNED NOT NULL DEFAULT 0,
`rating` DECIMAL(4,2) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY(`mail`),
INDEX (`name`,`mail`,`status`,`holiday`,`assigned_tickets`,`solved_tickets`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=55;
これらは users 行です。
(55, 'Admin', mail', 'code', 'code', NULL, '127.0.0.1', '2', '0', 'yes', 0, 0, 1, 4.00),
(62, 'Mario', 'mail', 'code', 'code', NULL, '87.8.28.216', '1', '0', 'yes', 2, 0, 0, 0.00);
そして、これはチケットの行です:
(60, 'enc_id', 'wwZs1amB', 9, 62, 55, 'Bell', 1, '', '0', '', '', '2013-08-10 12:30:48', '2013-08-10 12:30:48', '1', NULL);