以下 SQL 完美运行:
SELECT node_path, commenttext
FROM comments WHERE node_path ~ '*.5f985c80_5205_48cd_b198_1734e0a981d4.*';
但是以下给了我一个错误:
SELECT node_path, commenttext
FROM comments WHERE node_path ~ ('*.'||'5f985c80_5205_48cd_b198_1734e0a981d4'||'.*');
错误是:
ERROR: operator does not exist: ltree ~ text
LINE 1: ...e_path, commenttext FROM comments WHERE node_path ~ ('*.'||'...
^
HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
除了串联之外,我不确定两者之间的区别。