2016-06-16 47 views
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"; 

似乎不起作用。如果我刪除AND status='Coming Soon'它的作品。sql - double條件不起作用

+0

自動換行關行情形成在爲「key''而使用反引號 – Saty

+0

SATY'「電影名稱」列名,不使用不正當的別名般的地位,換句話說,你的意思是什麼? –

+0

這不是WHERE條件的問題。請分享您在運行此查詢時遇到的錯誤。 –

回答

4

使用backtic,而不是單引號的電影名稱和鍵和刪除別名狀態,如果電影的名字是一個名稱,而不是列使用單一的(因爲這可能造成在問題)

$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"; 

報價爲選擇的字面意義,但記得在條件

$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"; 
+0

如果'movie-name'不是列? –

+0

我已經更新了答案,但真正的問題與不正確使用別名有關 – scaisEdge