我有这段代码:
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "manufacturer m LEFT JOIN " . DB_PREFIX . "manufacturer_to_store m2s ON (m.manufacturer_id = m2s.manufacturer_id) WHERE m.manufacturer_id = '" . (int)$manufacturer_id . "' AND m2s.store_id = '" . (int)$this->config->get('config_store_id') . "'");
和数据库表:
manufacturer_id | name | image | sort_order
如何在列name
中以符号“B”或“9”开头的所有记录?
答案 0 :(得分:2)
... WHERE `name` LIKE 'B%' OR `name` LIKE '9%'
答案 1 :(得分:1)
SQL看起来像:
SELECT * FROM manufacturer m LEFT JOIN manufacturer_to_store m2s ON m.manufacturer_id = m2s.manufacturer_id
WHERE m2s.store_id = <some store id here>
AND (m.name LIKE 'B%' or m.name LIKE '9%')