mysql> desc no_report;
+----------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+----------------+----------------------+------+-----+---------+----------------+
| NRID | smallint(5) unsigned | | PRI | NULL |
auto_increment |
| Date | date | YES | | NULL |
|
| ManufacturerID | smallint(6) | YES | | NULL |
|
| OrderDate | date | YES | | NULL |
|
+----------------+----------------------+------+-----+---------+----------------+
etc ...
mysql> desc widgets_a;
+----------------------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default |
Extra |
+----------------------------+-------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL |
auto_increment |
| Date | date | YES | | NULL |
|
| ManufacturerID | smallint(6) | YES | | NULL |
|
| NumberUnits | int(11) | YES | | NULL |
|
| ContractNumber | text | YES | | NULL |
|
| OrderDate | date | YES | | NULL |
|
+----------------------------+-------------+------+-----+---------+----------------+
etc ...
mysql> desc widgets_b;
+----------------------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default |
Extra |
+----------------------------+-------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL |
auto_increment |
| Date | date | YES | | NULL |
|
| ManufacturerID | smallint(6) | YES | | NULL |
|
| NumberUnits | int(11) | YES | | NULL |
|
| ContractNumber | text | YES | | NULL |
|
| OrderDate | date | YES | | NULL |
|
+----------------------------+-------------+------+-----+---------+----------------+
etc ...
Brandon wrote:
Can you give the table structures? This looks like an interesting one to
try....
"Dave M" <di******@eswis.net> wrote in message
news:rh************@news.randori.com...
All
I've got a database that keeps track of sales of widgets. Each company
that belongs to my organiztion is to report their widget sales or no
sales every month.
There are several different types of widgets. Not all companies sell or
report all types of widgets.
We want to report how many companies have reported or not reported their
sales (ie. x companies of a possible y companies have reported sales
this month - y will always be the same - lets say 5).
Because of the way that sales are input, "big widgets" are reported in 2
different tables called widgets_a and widgets_b. If they don't have any
sales to report, they still report and it goes into a table called
no_reports. Each table has a couple of common fields - ManufacturerID
and OrderDate.
I can search all of the tables individually to find if a manufacturer
has reported -
SELECT DISTINCT ManufacturerID FROM widgets_a WHERE OrderDate >=
'2003-06-01' AND OrderDate <= '2003-06-30';
but I want to search through the 3 tables and find how many distinct
manufacturers have reported in the given month. I know this can be
accomplished through a join, but I need some help. Thanks in advance.
Dave