php - MySQL query to get data from two tables -


i have 2 tables, post , cart, when user adds item in case post in post table, post id, post name , user's name has added added cart table. want when user logs in, username matched in cart table retrieving post id , comparing post id in post table can retrieve whole post, below sketch of tables

             cart_item table | item_id    | post_id     | username     | |:-----------|------------:|:------------:| | 1          |        127  |     chrome           post table | post_id | make | price|seller| |:--------|------|-----:|:----:| | 127    |bmw   |$12000| joan     

the query should first user in cart table, when finds user, should cart items "post_ids" , match post_ids corresponding ones in post table, if found, should retrieve posts , show user. how can solve this? can me appreciate.

select post_table.* post_table left join cart_item on cart_item.post_id=post_table.post_id cart_item.username="chrome"; 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -