开发者

Problems with a query in MySql (LIKE between two table columns)

i have the following sql sentence:

    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%' 
AN开发者_高级运维D 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

The problem is that i want to compare the a.line column with the b.line column but it compares with the value as the string "b.line", not the value of this column, could you please help me?


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


WHERE a.line LIKE '%' || b.line || '%'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜