dpp3047 2015-05-06 19:56
浏览 54

在不同的MySQL列中搜索不区分大小写

On my website I have a search integrated. I tried full text search, but it is not case insensitive as I would like. Artist and song are in different columns in MySQL.

The code is:

public function search($query, $page_num = 1, $cid=null) {
    if (empty($page_num)) $page_num = 1;
    $items = $this->db->get_results('SELECT added, store.id, categories.id AS category_id, categories.name AS category_name, artist, song, file, size, youtube_url, downloads, hits
        FROM store LEFT JOIN categories ON (store.cid = categories.id)

        WHERE MATCH(artist, song, added) AGAINST ("+' . $this->db->escape($query) . '" IN BOOLEAN MODE)

        '. ($cid!==null ? ' AND store.cid = "'.intval($cid).'"' : '') .'
        ORDER BY added DESC
        LIMIT ' . ($page_num - 1) * SONGS_ON_PAGE . ', ' . SONGS_ON_PAGE, ARRAY_A);
  • 写回答

1条回答 默认 最新

  • dongtuo4723 2015-05-06 20:02
    关注

    You could return results from a query like this:

    SELECT * FROM store
    WHERE CONCAT(artist, song) LIKE '%<search>%'
    
    评论

报告相同问题?

悬赏问题

  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件