Reputation: 11
I have this query in my php and it seems to be fetching the wrong data set from my db.
$querystring = "
SELECT a.*,
b.itemcolour,
b.itemcolourname
FROM itemorders AS a
INNER JOIN catalogueitemscolour AS b
ON a.colourid = b.colourid
WHERE a.colourid IN(SELECT colourid
FROM itemorders
WHERE orderid = 61)
";
Here is a picture of my results
Can I know why it's not selecting the specific orderID of 61?
Upvotes: 1
Views: 67
Reputation: 1
Because you are not putting condition on orderID
, rather putting it on colorID
. What you actually want is this condition: WHERE a.orderID = 61
.
Upvotes: 0
Reputation: 37473
You can try below -
SELECT a.*, b.itemColour,b.itemColourName FROM itemorders
AS a INNER JOIN CatalogueItemsColour AS b ON a.colourID = b.colourID WHERE
a.orderID = 61
Upvotes: 1