Gossamer Forum
Home : General : Databases and SQL :

PostalCode hell!

Quote Reply
PostalCode hell!
I have a doosey of a problem...

I have a table holding the postal codes in a salesperson's territory, however, it only contains the BEGINNING of a postal code
(EX. L9 would give you any companies that have a postal code that starts with L9)

I have my search running like this:

SELECT * FROM Companies WHERE PostalCode LIKE 'L9%' OR PostalCode LIKE 'K4'

but if there are too many postalcodes for that salesperson, I get a "Query too complex" error. I would like to use the "LIKE ANY" Condition, but I can't then use a wildcard (EX ...WHERE PostalCode LIKE ANY(SELECT PostalCode FROM SalesPostalCodes WHERE SalesPerson=1) )

Does anybody know a solution to my problem? Is there any way to use a Wildcard in a "LIKE ANY" condition?

Thank you very, VERY much

Last edited by:

Wiggy: Oct 30, 2002, 2:04 PM
Quote Reply
Re: [Wiggy] PostalCode hell! In reply to
What database are you using?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] PostalCode hell! In reply to
In Reply To:
What database are you using?

Cheers,

Alex


I'm using an Access Database, being, uhh, accessed by SQL & ASP.NET

Thanks a lot
Quote Reply
Re: [Wiggy] PostalCode hell! In reply to
Hello Wiggly,

Depending on your Access database version, you may be running into a 64K query limit.

See : http://support.microsoft.com/...cid=KB;EN-US;q103429&

Also your query with WHERE PostalCode LIKE 'L9%' OR PostalCode LIKE 'K4'

is a bit confusing as : PostalCode = 'K4' may be best if you do not need a wild card.

Hope this helps

kode
Quote Reply
Re: [kode] PostalCode hell! In reply to
In Reply To:
Hello Wiggly,

Depending on your Access database version, you may be running into a 64K query limit.

See : http://support.microsoft.com/...cid=KB;EN-US;q103429&

Also your query with WHERE PostalCode LIKE 'L9%' OR PostalCode LIKE 'K4'

is a bit confusing as : PostalCode = 'K4' may be best if you do not need a wild card.

Hope this helps

kode


you're right, it should read PostalCode LIKE 'K4%'...
There's no way to use a Wildcard in a ANY (Subquery) scenerio?

Thanks for the responses guys!