开发者

SQLite query between two set of elements

I have two sets of elements A:[1,2,3,4] and B:[5,6,7,8] and I would like to know if it's possible to make a query to select all the stations that contai开发者_JAVA百科n at least one element in A and one element in B

SELECT * FROM Stations WHERE myStation.lines correspond to at least one in A AND at least one in B

myStation.lines is also a set of elements...

Thanks!!!


I think you are asking for this:

select * from Stations where lines IN 
(select distinct [column_name] from A) AND 
lines in (select distinct [column_name] from B) 


You can use SQL do this if there exists a function that will conduct the set operation in some WHERE clause. For what I know sqlite doesn't have such functions, but you can always create a user-defined function. Otherwise, you should normalize your data so that one record holds one value (only one of 1,2,3,4,....) and then you can join.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜