Forums / General Questions / sql query to output snail mail addresses?

sql query to output snail mail addresses?

Locked

Views: 1,027

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
24 Jan 2009, 9:45 PM
#1
filmfr3ak avatar

filmfr3ak

New Zenner

Join Date:
Jun 2006
Posts:
35
Plugin Contributions:
0

sql query to output snail mail addresses?

Need query to select orders by manufacturer id.
and return a list of customer names and addresses who have made orders from the specified manufacturer.

I've been trying to write an sql query to export a list of mailing addresses of customers who have purchased from specified manufacturers.

I can paste the query into my database myself, I just cant come up with a query that works. Everything I do pulls ALL of the addresses not ones that bought from that manufacturer only.

the effected tables and fields are: {I think}

zen_address_book >
customers_id
entry_firstname
entry_lastname
entry_street_address
entry_city
entry_postcode

zen_orders >
customers_id
orders_id

zen_orders_products >
orders_id
products_id

zen_products >
products_id
manufacturers_id

any ideas???

24 Jan 2009, 10:23 PM
#2
data_digger avatar

data_digger

Zen Follower

Join Date:
Jan 2009
Posts:
222
Plugin Contributions:
2

Re: sql query to output snail mail addresses?

select o.delivery_name, o.delivery_company, o.delivery_street_address, o.delivery_suburb, o.delivery_city, o.delivery_postcode, o.delivery_state, o.delivery_country
from orders o JOIN orders_products op USING(orders_id) JOIN products p USING(products_id) JOIN manufacturers m USING(manufacturers_id)
where m.manufacturers_id = id_of_your_manufacturer

Or, if You want select manufacturer by its name:

select o.delivery_name, o.delivery_company, o.delivery_street_address, o.delivery_suburb, o.delivery_city, o.delivery_postcode, o.delivery_state, o.delivery_country
from orders o JOIN orders_products op USING(orders_id) JOIN products p USING(products_id) JOIN manufacturers m USING(manufacturers_id)
where m.manufacturers_name like 'name_of_manufacturer'