Search for value within BLOB column in MySQL

我怕爱的太早我们不能终老 提交于 2019-12-22 01:26:27

问题


How can I search inside Blob column in MySQL for some values ? and Is that possible ?


回答1:


You should be able to search blobs like other text fields:

SELECT * 
FROM tablename 
WHERE blob_field_name LIKE '%value%'

One thing to notice is that search will be case-sensitive!

Anyway, if possible, it's better to use a TEXT field.




回答2:


If you want to make it work for both uppercase, lowercase or mixed... Make the search string in lower case before applying in mysql query and use LOWER() mysql function in query. make sure to escape string for mysql.

$search_text = strtolower($search_text);

$query = 'SELECT * 
FROM tablename 
WHERE LOWER( blob_field_name ) LIKE "%$search_text%"';


来源:https://stackoverflow.com/questions/3746756/search-for-value-within-blob-column-in-mysql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!