jeudi 16 avril 2015

search operation for CSV field sqlite

I have a SQLite table named User . Each User has a primary UserID and multiple SecIDs (all integers). The SecIDs are stored in CSV format as a single field (type is String). For example, suppose User1 has SecIDs as 4,5,6,7 and User2 has SecIDs as 8,9,55,66.


So for User1 :-

UserID = 1

SecIDs = "4,5,6,7"

And for User2 :-

UserID = 2

SecIDs = "8,9,55,66" (And so on)


Now my question is- I have a particular SecID say 5. And I have to extract the UserID corresponding to that (which is 1). So what would be the Query for this operation?


P.S- There could be lakhs and lakhs of User Records in my SQLite table. So the search query should be an optimized for minimum time consumption.


Aucun commentaire:

Enregistrer un commentaire