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 =4
into 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
精彩评论