Reputation: 464
I have Two tables.Table one is the master table containing name of some products, table two save the product assigned to specific users.Then i need to get the product list from the master table(table 1) which is not added under the user in table 2.
above image shows the table structure.
So when I chose user 11 its should not how the product_name C. How can I write the MySQL query for this.
Upvotes: 0
Views: 81
Reputation: 1397
You may try this query
SELECT table1.product_name FROM `table1`
INNER JOIN table2 on table2.p_id = table1.p_id
WHERE table2.user_id = 11
Upvotes: 2
Reputation: 1573
I guees below query should work.
SELECT p1.p_id,p1.product_name FROM table_1 AS p1
INNER JOIN table_2 AS p2
ON p2.p_id = p1.p_id
WHERE p2.user_id = '11'
Upvotes: 1