与列名称上的%类似 [英] LIKE with % on column names
本文介绍了与列名称上的%类似的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的查询,导致语法错误:
Here is my query that results in a syntax error:
SELECT *
FROM account_invoice,sale_order
WHERE sale_order.name LIKE %account_invoice.origin%
account_invoice.origin字段包含sale_order.name,以及其他文本,因此我需要在account_invoice.origin字符串中的任何位置匹配sale_order.name字符串。
The account_invoice.origin field contains the text of sale_order.name, plus other text as well, so I need to match sale_order.name string anywhere in the account_invoice.origin string.
我正在使用PostgreSQL 8.4。
I'm using PostgreSQL 8.4.
推荐答案
尝试一下
SELECT *
FROM account_invoice,sale_order
WHERE sale_order.name LIKE '%' || account_invoice.origin || '%'
%
需要单引号,因为模式是一个字符串。
%
needs single quote because the pattern is a string.
||
是串联。
这篇关于与列名称上的%类似的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文