• python3 mysql like 查询


    SELECT fileid 
        FROM files 
        WHERE description LIKE '%%%s%%' 
            OR filename LIKE '%%%s%%' 
            OR uploader LIKE '%%%s%%' 
            ORDER BY fileid DESC" % (search, search, search)  

    具体示例

        def find_info_by_param(self, conn,Title,Organization,InfoType ,PubDate1,PubDate2,offsetnum,limitnum):
            '''
            根据众多条件返回检索结果,其中包含了mysql的like查询
            :param conn:
            :param Title:
            :param Organization:
            :param InfoType:
            :param PubDate1:
            :param PubDate2:
            :param offsetnum:
            :param limitnum:
            :return:
            '''
            self.conn = conn
            result = 0
            try:
                curr = conn.cursor()
                sqlStr = " select Id,Title,PubDate,Organization,EffectDate,Content,Url,IndexNum,`Type`,PolicyNo,Effect,Keyword,Abstract,InfoType,Creator,CreateTime from Policys where Title like '%%%s%%' and Organization like '%%%s%%' and  InfoType ='%s' and (PubDate between '%s' and '%s') limit %s,%s "%(Title,Organization,InfoType,PubDate1,PubDate2,offsetnum,limitnum)
                print(sqlStr)
                # args =()
                curr.execute(sqlStr)
                rows = curr.fetchall()
                return rows
            except pymysql.Error as e:
                print('find_policy_by_id error %s' % e)
                conn.close()
            return result
  • 相关阅读:
    图片放大功能
    谈论算法
    socket基础
    js实现快速排序
    mysql死锁问题分析(转)
    MVCC 专题
    ActiveMQ持久化方式(转)
    消息队列中点对点与发布订阅区别(good)
    tomcat下部署activemq(转)
    Android文件下载(实现断点续传)
  • 原文地址:https://www.cnblogs.com/ningy1009/p/12930793.html
Copyright © 2020-2023  润新知