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:
SELECT * 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.