testingpoke1 - Tuesday, November 28, 2017 8:05 AM
Well look at your query (which is way more complicated than it needs to be). You have:
SELECT * FROM cart_item WHERE id_cart IN (SELECT id_cart FROM purchase)
This by definition will prevent id_product 3 from appearing in your results because you do not have a row in the purchase table for id_cart 2. I am willing to help you but you have to explain what it is you are trying to do here.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/