sql - SQL查询缺少选择语句获取数据错误
问题描述
我正在使用 SQL 查询获取一些问题数据,但未获取黑色显示。
我在这里分享这个查询。请帮我。
SQL查询在这里
select * from products where hitproduct='0' ORDER BY id DESC and user_id='$user_id'
解决方案
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;
注意使用?
. 这代表一个参数占位符。不要使用参数值来处理查询字符串!学会正确使用参数。
推荐阅读
- node.js - NodeJS Joi 验证:需要两个字段或第三个字段
- sass - 复选框默认检查并在 React.js 中禁用不工作
- python - 在python中附加json文件
- angular - 如何使用 Jasmine Marbles 为 Angular 的 HttpClient 编写单元测试?
- java - 如何在 JavaFX 运行时创建动态添加列的 TableView?
- reactjs - 使用带有 redux-thunk 的异步操作创建器时反应获取无效状态
- swift - UIInputViewController 上未调用 SwiftUI 按钮
- javascript - 在 JavaScript (.js) 文件中包含 HTML
- python - 使用日期时间子选择的 date_range 出错
- javascript - 在 Javascript 块中将 PHP 插入 HTML