首页 > 解决方案 > SQL查询缺少选择语句获取数据错误

问题描述

我正在使用 SQL 查询获取一些问题数据,但未获取黑色显示。

我在这里分享这个查询。请帮我。

SQL查询在这里

select * from products where hitproduct='0'  ORDER BY id DESC and  user_id='$user_id'

标签: sql

解决方案


SQL 查询只有一个where子句。大概,你打算:

select p.*
from products p
where user_id = ? and
      hitproduct = 0 -- looks like a number, so I assume it is
order by id desc;

注意使用?. 这代表一个参数占位符。不要使用参数值来处理查询字符串!学会正确使用参数。


推荐阅读