1
$sql3 = "SELECT DISTINCT id as id,status as status,'movie-name' as 'key',
moviename as value,poster as cover 
FROM movie 
WHERE id='$movieid' AND status='Coming Soon' 
ORDER BY id DESC LIMIT 6";

does not seems to work. If I delete AND status='Coming Soon' it works.

Ankit Agrawal
  • 2,426
  • 1
  • 13
  • 27
John Doe
  • 67
  • 1
  • 2
  • 8

1 Answers1

4

Use backtic and not single quote for movie-name and key and remove alias for status (because this could create problem in where)

 $sql3 =  "SELECT DISTINCT id ,status ,`movie-name`  as `key`,
             moviename as value,poster as cover 
           FROM movie 
           WHERE id='$movieid' 
           AND status='Coming Soon' 
           ORDER BY id DESC 
           LIMIT 6";

if movie-name is a name and not a column use single quote for select the literal value but remember of don't use improper alias like status in where condition

 $sql3 =  "SELECT DISTINCT id ,status ,'movie-name'  as `key`,
             moviename as value,poster as cover 
           FROM movie 
           WHERE id='$movieid' 
           AND status='Coming Soon' 
           ORDER BY id DESC 
           LIMIT 6";
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107