Code: Select all
select * from ticket where queue_id = '12';
Moderator: crythias
Code: Select all
select * from ticket where queue_id = '12';
Code: Select all
mysql> select * from ticket where queue_id = '12' and customer_id = 'something' and create_time between date_sub(now(), interval 1 month) and now() and ticket_state_id = '2';
Code: Select all
mysql> describe ticket_history;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| name | varchar(200) | NO | | NULL | |
| history_type_id | smallint(6) | NO | MUL | NULL | |
| ticket_id | bigint(20) | NO | MUL | NULL | |
| article_id | bigint(20) | YES | MUL | NULL | |
| type_id | smallint(6) | NO | MUL | NULL | |
| queue_id | int(11) | NO | MUL | NULL | |
| owner_id | int(11) | NO | MUL | NULL | |
| priority_id | smallint(6) | NO | MUL | NULL | |
| state_id | smallint(6) | NO | MUL | NULL | |
| valid_id | smallint(6) | NO | MUL | NULL | |
| create_time | datetime | NO | MUL | NULL | |
| create_by | int(11) | NO | MUL | NULL | |
| change_time | datetime | NO | | NULL | |
| change_by | int(11) | NO | MUL | NULL | |
+-----------------+--------------+------+-----+---------+----------------+
15 rows in set (0.02 sec)
Code: Select all
LEFT JOIN ticket_history USING queue_id WHERE ticket_history.queue_id = 12;