I am fairly new to MySQL and SQL in general. I have three tables, acc,sales1,sales2. All have acctno in common. acc is general customer table with lots of information. sales1 is a generated table of sales for specific customer from a given month/year. sales2 is the sale as sales1 except for a different month/year. I need:

acc.name, acc.phone, acc.acctno, sales1.amt as mo1sales, sales2.amt as mo2sales, (sales1.amt - sales2.amt) as diff SORT by diff

I need all data in sales1 and sales2, but only for records from acc that are in either/both sales1, sales2.

I tried:
select .... from acc,sales1,sales2 where acc.acctno=sales1.acctno and acc.acctno=sales2.acctno
I got only records which were in all three tables.


I looked at using join, but can not determine which style of JOIN I need, nor how to write the JOIN statement. Can someone please help?



Patrick J. Shoaf, Systems Engineer
<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]

Midmon Internet Services, LLC
100 Third Street
Charleroi, PA 15022
http://www.midmon.com
Phone: 724-483-2400 ext. 105
 or    888-638-6963
Fax:   724-489-4386



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to