问题描述
我正在尝试加入两个表.我遇到的问题是我要加入的列之一是列表.
I'm tryin to join two tables. The problem i'm having is that one of the columns i'm trying to join on is a list.
因此可以使用"IN"而不是"="联接两个表.遵循
So is it possible to join two tables using "IN" rather than "=". Along the lines of
SELECT ID
FROM tableA INNER JOIN
tableB ON tableB.misc IN tableA.misc
WHERE tableB.miscTitle = 'help me please'
tableB.misc = 1
tableA.misc = 1,2,3
预先感谢
推荐答案
没有主要的变通办法,就不可能实现您想要的一切.不要存储要加入列表的商品!实际上,逗号分隔的列表几乎永远不应存储在数据库中.仅当这是注释类型信息而不再需要在clasue或join的查询中使用时,才可以接受.
No what you want is not possible without a major workaround. DO NOT STORE ITEMS YOU WANT TO JOIN TO IN A LIST! In fact a comma delimited list should almost never be stored in a database. It is only acceptable if this is note type information that will never need to be used in a query where clasue or join.
如果您坚持使用这种可怕的设计,则必须将列表解析为临时表或表变量,然后通过该表进行联接.
If you are stuck with this horrible design, then you will have to parse out the list to a temp table or table variable and then join through that.
这篇关于SQL-联接表,其中的一列是列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!