需要使用带有限制的左连接,但它工作错误

I have two sql query:

1)

SELECT DISTINCT item_id  
FROM sh_itemviews WHERE login='".$login."' 
ORDER by time DESC LIMIT 5"

2)

SELECT * 
FROM sh_item WHERE id=itemIdFrom  sh_itemviews "

So i want to do it better and i'm trying to use LEFT JOIN:

SELECT DISTINCT * 
FROM sh_itemviews 
      LEFT JOIN sh_item ON sh_item.id = sh_itemviews.item_id; 
WHERE sh_itemviews.login='".$login."' 
ORDER by sh_itemviews.time DESC LIMIT 5"

Like a result i have all data where sh_item.id = sh_itemviews.item_id; but other constructin WHERE is ignored. What i'm doing wrong? Thanks!

Extra semi column before the WHERE clause was the reason, Find the updated query below

 SELECT DISTINCT * 
 FROM sh_itemviews 
      LEFT JOIN sh_item ON sh_item.id = sh_itemviews.item_id 
 WHERE sh_itemviews.login='".$login."' 
 ORDER by sh_itemviews.time DESC LIMIT 5"

You have a semicolon just before the WHERE statement.

"SELECT DISTINCT * FROM sh_itemviews LEFT JOIN sh_item ON sh_item.id = sh_itemviews.item_id**;** WHERE sh_itemviews.login='".$login."' ORDER by sh_itemviews.time DESC LIMIT 5"

The correct one is:

"SELECT DISTINCT * 
FROM sh_itemviews 
LEFT JOIN sh_item ON sh_item.id = sh_itemviews.item_id 
WHERE sh_itemviews.login='".$login."' 
ORDER by sh_itemviews.time DESC 
LIMIT 5"

You make incorrect syntax before where Try this syntax

SELECT DISTINCT * 
FROM sh_itemviews 
LEFT JOIN sh_item ON sh_item.id = sh_itemviews.item_id

WHERE sh_itemviews.login='".$login."' 
ORDER by sh_itemviews.time DESC
LIMIT 5"