Skip to content
Advertisement

SQL query missing select statement fetching data error

I am using SQL query fetching some issue data is not fetching black show.

I am sharing this query here. Please help me.

SQL query here

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

Advertisement

Answer

A SQL query only has one where clause. Presumably, you intend:

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

Note the use of ?. This represents a parameter placeholder. Don’t munge query strings with parameters values! Learn to use parameters properly.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement