我有两个表包含这样的客户ID:
(SELECT * FROM customers WHERE cellular = '$cellular' OR id IN(SELECT customer FROM clients WHERE number=$cellular ) )
当我搜索客户蜂窝客户端或蜂窝时,这个mysql查询需要30秒。 我怎么能更快?
答案 0 :(得分:0)
尝试MySQL join
SELECT * FROM customers left join clients
on customers.id=clients.customer
where clients.number=$cellular or customers.cellular = '$cellular'
或尝试此查询: -
SELECT * FROM customers inner join clients
on customers.id=clients.customer
where clients.number=$cellular or customers.cellular = '$cellular'