选择具有2种不同状态的所有项目,以便选择状态为a且状态为b的项目

时间:2017-06-30 05:21:05

标签: php mysql sql codeigniter

SELECT
    `itemmaster`.*
FROM
`sds`.`itemmaster`
    WHERE `item_stock_code` = (SELECT
    `item_stock_code`
FROM
    `sds`.`itemmaster`
WHERE (`item_stock_code` ='221F0009DN00H2A')) AND 
`item_stock_code` = (SELECT
    `item_stock_code`
FROM
    `sds`.`itemmaster`
WHERE (`item_stock_code` ='221F0010DN00H2A'));

1 个答案:

答案 0 :(得分:1)

对于Codeigniter,您可以使用:

$this->db->where_in('your_column', array('status1','status2'));

请参阅此CI参考Link:or_where_in

在SQL中:

"SELECT * from your_table Where your_column IN (".implode(',',$your_satus_array).")";