情况一
search = request.form['search']
sql = "select * from posts where title like '%"+search+"%' order by created desc"
情况二
<select id="searchClass" resultMap="paperClassEntityList" parameterType="PaperClassEntity">
select * from paper_categor where category like concat('%', #{category},'%') and is_deleted=1
</select>
这篇博客探讨了在Python中使用Flask框架处理HTTP请求,并展示了如何从请求中获取参数来执行SQL查询。文章以两个实例说明,分别是根据搜索关键字动态查询posts表和paper_categor表,通过LIKE操作符进行模糊匹配并按时间降序排列结果。内容涵盖了SQL语句的构造以及在模板中的使用。
17万+

被折叠的 条评论
为什么被折叠?



