开发者

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

开发者 https://www.devze.com 2023-04-01 07:39 出处:网络
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)

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

精彩评论

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