是否可以形成一个查询,其中table1.first_name +“”+ table1.last_name匹配table2.customer_name?
IE:customers.first_name =“John”customers.last_name =“Doe”
orders.customer_name =“John Doe”
在我看来,这将是一个常见的查询,但只是无法直观地提出语法。
此外,我被认为这不是一个“最佳实践”解决方案(使用id字段会更好),但如果我无法控制架构,我只想知道我的方法之类的东西是否可能。
您正在寻找concat
where concat(customers.first_name,' ',customers.last_name) = orders.customer_name
您可以连接值并比较结果,如下所示:
(customers.first_name || ' ' || customers.last_name) = orders.customer_name
支架只是为了便于阅读