Forums / General Questions / Need list of customers only in specific state

Need list of customers only in specific state

Locked

Views: 1,381

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
21 May 2008, 2:20 AM
#1
dcfxking avatar

dcfxking

New Zenner

Join Date:
Jun 2006
Location:
Boston, MA
Posts:
80
Plugin Contributions:
0

Need list of customers only in specific state

Hey all,

I need to pull the email addresses for customers in a few specific states as we have a promotion that we want to inform them about that is only available ina few states. This is not something I have to do often so I dont mind running a query in phpMyAdmin. I am not too familiar with SQL and did notice that the customers email address is in one table (zen_customers) while their email address is in (zen_address_book).

Has anyone done this before and can anyone help me with the syntax or know if a way this can be done within the zencart admin? We do have the newsletter export mod so we can export all our customers but I do not belive there is a way to filter by states.

I have been playing with it but cant get it to work. I had something like this but it keeps pulling every cusomer not just the ones in the states I want:

SELECT customers_email_address FROM zen_customers, zen_address_book WHERE entry_state = "MA" or "NH" or "RI" or "ME" or "VT"

21 May 2008, 3:06 AM
#2
elastic avatar

elastic

New Zenner

Join Date:
Dec 2007
Location:
New Jersey
Posts:
76
Plugin Contributions:
0

Re: Need list of customers only in specific state

hi dcfxking.... try this. i got this to work on my db. you just have some quotes around things you don't need:

SELECT customers_email_address
FROM zen_customers, zen_address_book
WHERE entry_state = "MA"
OR "NH"
OR "RI"
OR "ME"
OR "VT"
LIMIT 0 , 30

hmmn. really?

21 May 2008, 3:49 AM
#3
dcfxking avatar

dcfxking

New Zenner

Join Date:
Jun 2006
Location:
Boston, MA
Posts:
80
Plugin Contributions:
0

Re: Need list of customers only in specific state

Thanks Elastic,

That query runs but it doesnt filter out only customers in those states, it actually lists the email address for every single customer still.

21 May 2008, 4:52 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Need list of customers only in specific state

Zen Cart doesn't store a state name if the customer's address fits within a defined zone. Instead, it stores the zone number in entry_zone.
You could do a join on the zones table to match up with the state codes you desire.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 May 2008, 3:36 PM
#5
dcfxking avatar

dcfxking

New Zenner

Join Date:
Jun 2006
Location:
Boston, MA
Posts:
80
Plugin Contributions:
0

Re: Need list of customers only in specific state

DrByte:

Zen Cart doesn't store a state name if the customer's address fits within a defined zone. Instead, it stores the zone number in entry_zone.
You could do a join on the zones table to match up with the state codes you desire.

Thans that makes sense why nothing I was trying as working. Can you explain the ones a little more? Is there a zone # for each state? If I go into my customers section in admin and open up a customer it does have a state...where is this data stored?

Can you give an example of how that query would look in order to grab customers mail addresses only if they are in a certain group of states?