string - how to use replace on a left join statement
问题描述
I have two tables, one of them has a field with strings like that '1111AAA', the other one has the same field but with this structure '1111 AAA'. I want to replace the blank space with '', but I have an error near the ON of the left join.
I put the code below:
select idticket, bt.matricula, bv.vehicle
from b_ticket bt
left JOIN b_vehicle bv ON REPLACE(bv.matricula, ' ', '') ilike ON REPLACE(bt.matricula, ' ', '')
where date_start >= '2019/01/01/'
and date_end <= '2020/01/01'
I cannot change the values of any of the two tables. And I also try TRIM function, but it doesn't work because it removes blank spaces of the start and end of the string, not between words.
Any idea?
Thanks!
Error message: ERROR: sintax error near «ON» LINE 3: ... bv ON REPLACE(bv.matricula, ' ', '') ilike ON REPLACE...
解决方案
很可能您的子句中有一个无关的ON
关键字:JOIN
SELECT
idticket, bt.matricula, bv.vehicle
FROM
b_ticket AS bt LEFT JOIN b_vehicle AS bv
ON REPLACE(bv.matricula, ' ', '') ILIKE REPLACE(bt.matricula, ' ', '')
WHERE
date_start >= '2019/01/01/' AND date_end <= '2020/01/01';
正如错误所述:谓词必须是任何有效的布尔表达式,但其中不能有ON
关键字。
推荐阅读
- vue.js - Vue 3 中的 Draggable 不会显示值
- c# - 在 cosmos DB 中显示日期
- ubuntu - 从 Ubuntu 20.04 连接时 Citrix Workspace SSL 错误 61
- python - 使用 GNN 进行二元分类的验证准确度不会增加
- c# - 为什么我的 xunit 测试结果中会出现 System.ArgumentException?
- icons - 如何在 Gnome 文件管理器 Nautilus 中增加文件夹和符号链接的自定义图标的可见大小?
- android - 如何过滤firebase数据以显示在recyclerview上
- javascript - 使用渐进式 Web 应用程序 (PWA) 打印
- activerecord - yii hasone 与条件的关系
- angularjs - 套接字的“离开”是否自动转换为接收者的“离开”?