请我在这里有这个查询,我用它来从数据库中提取一些行。
$rs = mysql_query("SELECT u.*, SUM(c.ts) AS total_sum1, SUM(m.bv) AS total_sum
FROM users u
LEFT JOIN
(SELECT user_id ,SUM(points) AS ts FROM coupon GROUP BY user_id) c
ON u.user_id like'%$search%'
LEFT JOIN
(SELECT user_id ,SUM(points) AS bv FROM matching GROUP BY user_id) m
ON u.user_id=m.user_id
GROUP BY u.user_id limit $offset,$rows");
我需要对其进行修改,使其仅查询满足此条件的行:
u.user_id like '%$search%'
我应该把上述条件放在哪里?我尝试添加一个 AND 运算符,但它仍然不会给出一行,因为 user_id 彼此不同。
谢谢