【发布时间】:2020-04-29 22:59:58
【问题描述】:
嗨,我的 sqltable 中有 2 个表,其中我的第一个表的 id 为 111,112,113 等,第二个表具有相同的列也有列 id,其中包含 111|aa,112|ab,114|ad 等值,我需要从第二个表中选择包含第一列的部分 id 的所有 id,例如第二个表包含 111 和 112,它们也在 table1 中作为 111 和 112 我如何选择那些在查询下尝试但没有得到结果的记录。
select t1.id,t2.id from table1 t1 left outer join table2 t2 where t2.id like t2.id +'%'
also tried.
select t1.id,t2.id from table1 t1 left outer join table2 t2 on t2.id like t2.id +'%'
谁能给我一个提示我应该怎么做。
【问题讨论】:
-
我删除了不兼容的数据库标签。请仅使用您真正使用的数据库进行标记。
标签: sql