query to show difference of table A and table b.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
monindra1984
Forum Newbie
Posts: 14
Joined: Wed Mar 18, 2009 10:35 am

query to show difference of table A and table b.

Post by monindra1984 »

Dear frends,

there are two TABLE A (CUSTOMER_ID) and TABLE B (CUSTOMER_ID,ITEM1,ITEM2,...,ITEM36). Table A stores the permanent customers names. Table B keeps the demand places by any customer in Table A..

I wanted to find out which customers_id only who have not placed demand for items. I was trying do it by Left Join but i cound't...

pls guys help me out.. I m not good at database MYSQL. I want the query for MYSQL.

Thanks with anticipation

Monindra Masia
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: query to show difference of table A and table b.

Post by susrisha »

Code: Select all

 
SELECT DISTINCT customer_id
FROM tbl_customer1
WHERE (
customer_id
) NOT 
IN (
 
SELECT customer_id
FROM tbl_customer2
 
You may replace the table names..

i have renamed Table A to tbl_customer1 and Table B to tbl_customer2.
Post Reply