0
我正在使用MYSQL/Codeigniter。 MySQL查詢如何可以忽略的條件,如果傳遞的值是空的,這樣的例子:如果值爲空,則忽略條件MYSQL/Codeigniter
function get_category($category_id = 0){
return $this->db->query("SELECT * FROM {$this->table} c
INNER JOIN db_category_event ce
ON ce.category_id = c.category_id
INNER JOIN db_event_type e
ON e.event_id = ce.event_id
WHERE c.category_id = {$category_id}
WHERE c.visible = 1 AND e.visible = 1")
->result();
}
謝謝,它的工作正常:) –