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 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败