doucheng4660 2016-07-02 04:21
浏览 42
已采纳

从db中检索值,该值以json编码格式存储 - Mysql

enter image description here

Friends from the above image I have saved the values of category_id in json_encode format directly and for processing , I'm retrieving the values but i'm not getting the result as expected . My requirement is I need to retrieve the value of rss_url_id which belongs to category_id 1 , it should return rss_url_id 2 .

I use the query

SELECT rss_url_id FROM rss_url  WHERE `status` = 0 AND REPLACE( REPLACE(`category_id`,'[', '' ) , ']', '' ) LIKE '%1%'

But this query returns the both the result as in the first row it contains value 10 as i'm using like %1% it returns both the result, is there is any alternate query to return only the 2nd row . if i give the value as 1 .

  • 写回答

1条回答 默认 最新

  • dpa31905 2016-07-02 08:29
    关注

    You can try

    SELECT rss_url_id FROM rss_url  WHERE `status` = 0 AND `category_id` LIKE '%"1"%'
    

    Keep your category_id (to be searched) in double quotes

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析