douka19950505 2015-09-25 21:01
浏览 39
已采纳

PHP / Mysql:搜索序列化数据的字符串[重复]

This question already has an answer here:

I have started work on a project that someone else created, this is what he has done:
In a mySql table he has a TEXT field called "allData", in that field he has serialized records that look like this

a:13:{s:12:"currencyCode";s:3:"SEK";s:11:"senderEmail";s:18:”xxxxxgu7@gmail.com";
s:4:"HASH";s:32:"ebdeb85d094cefd102b630fa9e69d9ca";}

(There's a lot more data but I cut it down by around 95% so it would not mess up this page)

Any idea how I can search the above data for senderEmail or HASH?

</div>
  • 写回答

2条回答 默认 最新

  • douzhong1730 2015-09-25 21:13
    关注
    SELECT * FROM table WHERE allData LIKE '%"xxxxxgu7@gmail.com"%' AND allData LIKE '%"ebdeb85d094cefd102b630fa9e69d9ca"%' LIMIT 1;;
    

    This example should allow you to search for a specific HASH and senderEmail in the table and return that entry if a match of both fields exist in the serialized data. This would be useful to put into a view so that it can be retrieved quickly and easily, and you of course can see where you would want to change the email and hash in the query. In this example it will return that exact entry.

    More information:

    MySQL Like Function

    Search inside serialize data with MYSQL

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵