MySql中的查询问题(两个表列之间的LIKE)

时间:2011-09-12 18:56:02

标签: mysql

我有以下sql语句:

    SELECT a.id_payment, a.id_adjustment, a.line, b.amount, a.name, a.id_user, c.name, a.amount_before_discount, a.percentage_discount, a.amount_discount, b.date, b.sucursal 
FROM es_payment a, es_payments_successful b, es_payment_adjustment c 
WHERE a.line LIKE 'b.line%' 
AND a.id_adjustment = c.id_adjustment 
AND ((UNIX_TIMESTAMP(b.date) >= UNIX_TIMESTAMP('2011-09-01')) 
AND (UNIX_TIMESTAMP(b.date) <= UNIX_TIMESTAMP('2011-09-12'))) 
GROUP BY a.id_payment

问题是我想将a.line列与b.line列进行比较,但是它将值与字符串“b.line”进行比较,而不是此列的值,请问您能帮帮我吗?

2 个答案:

答案 0 :(得分:6)

WHERE a.line LIKE CONCAT(b.line, '%')

答案 1 :(得分:1)

在哪里a.line LIKE'%'|| b.line || '%'