开发者

sql search for a number into a BLOB (list of numbers)

I've stored an ArrayList of longs (ID's) into a Blob column. (followed question: BLOB vs. VARCHAR for storing arrays in a MySQL table)

That works, but now I've a problem: how can I search into that BLOB?

Imagine I've stored this numbers into the BLOB: 1,2,3,4 And what I want to do is:

开发者_如何学GoSELECT * FROM table WHERE blob_column CONTAINS 3

Is it possible?


The simple answer is "No, it's not possible". Your BLOB contains a serialised java object - and the database knows nothing about it's implementation.

When designing a database, you should always think about how you will need to access the data. In your case, you would be much better off having a separate table, which would contain your ID's from the list in separate rows. Then you could simply join that table into your query.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜