开发者

display from database

SELECT * FROM `tbl_wines` 
LEFT JOIN `tbl_wines_attrib` 
ON `tbl_wines`.`intWinesID` = `tbl_wines_attrib`.`intWinesID` 
AND `tbl_wines_attrib`.`intAttributeValueId` = 4 
WHERE `intStatus` = 1 
LIMIT 0 , 20 

I need to know if this query is correct. But am getting all the values from tbl_wines not only the value where intAttributeValueId 开发者_C百科= 4.

Can anyone help out?


It looks like that condition has been placed as part of your JOIN rather than a WHERE condition. Instead try the following, moving tbl_wines_attrib.intAttributeValueId =4into the WHERE clause.

SELECT * FROM `tbl_wines` LEFT JOIN `tbl_wines_attrib` ON `tbl_wines`.`intWinesID` = `tbl_wines_attrib`.`intWinesID` WHERE `tbl_wines_attrib`.`intAttributeValueId` = 4 AND `intStatus` =1 LIMIT 0 , 20 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜