mysql中的多行和多列条件

时间:2017-02-17 02:55:10

标签: mysql

使用此查询,

select *, from_unixtime(date_modified, '%Y %D %M %h:%i:%s') as date_m 
from orc_bug_history_table v
where field_name = 'resolution'
and v.old_value IN ('6','60', '201', '202', '211', '221')
and bug_id ='630021'

我得到以下结果,

3462530 1001    630021  resolution  6   60  0   1484900395  2017 20th January 04:19:55
3462531 1001    630021  resolution  60  201 0   1484900610  2017 20th January 04:23:30
3462533 1001    630021  resolution  201 202 0   1484900775  2017 20th January 04:26:15
3462538 1001    630021  resolution  202 211 0   1484900926  2017 20th January 04:28:46
3462546 1001    630021  resolution  211 221 0   1484901180  2017 20th January 04:33:00
3462552 1001    630021  resolution  221 85  0   1484901557  2017 20th January 04:39:17

我将查询限制在bug_id =' 630021'。但我需要的是,我需要检索所有bug_id,它们具有与查询中提到的old_value完全相同的行序列。即(' 6',' 60',' 201',' 202',' 211',&#39 ; 221&#39)。我需要这个序列。我的表包含其他旧值,而不是这里提到的值。而一些bug_id可能只提到了很少的值而不是全部。

我试过IN ALL,但似乎只能在Oraclesql中使用而不能在mysql中使用。我也试过以下但是无法找到正确的方法。

select *, from_unixtime(date_modified, '%Y %D %M %h:%i:%s') as date_m 
from orc_bug_history_table v
where field_name = 'resolution'
and v.old_value IN (select '6','60', '201', '202', '211', '221' from dual)
and bug_id ='630021'

预期o / p

3462530 1001    630021  resolution  6   60  0   1484900395  2017 20th January 04:19:55
3462531 1001    630021  resolution  60  201 0   1484900610  2017 20th January 04:23:30
3462533 1001    630021  resolution  201 202 0   1484900775  2017 20th January 04:26:15
3462538 1001    630021  resolution  202 211 0   1484900926  2017 20th January 04:28:46
3462546 1001    630021  resolution  211 221 0   1484901180  2017 20th January 04:33:00
3462552 1001    630021  resolution  221 85  0   1484901557  2017 20th January 04:39:17
3462551 1001    630022  resolution  6   60  0   1484900395  2017 20th January 04:19:55
3462552 1001    630022  resolution  60  201 0   1484900610  2017 20th January 04:23:30
3462553 1001    630022  resolution  201 202 0   1484900775  2017 20th January 04:26:15
3462554 1001    630022  resolution  202 211 0   1484900926  2017 20th January 04:28:46
3462555 1001    630022  resolution  211 221 0   1484901180  2017 20th January 04:33:00
3462556 1001    630022  resolution  221 85  0   1484901557  2017 20th January 04:39:17

任何帮助!!

0 个答案:

没有答案