• 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
  • 相关阅读:
    hdu 1978
    hdu 2700
    hdu 1176
    hdu 2390
    hdu 2707
    hdu 1804
    hdu 2703
    hdu 2572
    hdu 1171
    React有状态组件和无状态组件
  • 原文地址:https://www.cnblogs.com/ningy1009/p/12930793.html
Copyright © 2020-2023  润新知