帮助请问...如何更正此代码?
SELECT Products.ProductID, Products.Name, Categories.CatName, " +
"Products.Description, Products.Price FROM Products INNER JOIN Categories ON " +
"Products.CatID = Categories.CatID ORDER BY Products.Price DESC WHERE " + column + " LIKE '%" + keyword + "%'";
答案 0 :(得分:0)
order by
应该在where
子句
"SELECT Products.ProductID, Products.Name, Categories.CatName, " +
"Products.Description, Products.Price FROM Products INNER JOIN Categories ON " +
"Products.CatID = Categories.CatID " +
"WHERE " + column + " LIKE '%" + keyword + "%'";
"ORDER BY Products.Price DESC"
正如其他评论所说,您应该考虑使用SQLParameters
来避免 SQL注入
答案 1 :(得分:0)
您想要的反注入SQL代码?
如下:
"SELECT Products.ProductID, Products.Name, Categories.CatName, " +
"Products.Description, Products.Price FROM Products INNER JOIN Categories ON " +
"Products.CatID = Categories.CatID WHERE " + column +
"LIKE CONCAT('%'," + keyword + ",'%')" +
"ORDER BY Products.Price DESC";