473,557 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Brick Codes

Hi,

I have a table of Locations around the country. My system produces reports
based on these Locations. I also have a table containing Brick Codes e.g.

Brick Post Code
AB51 AB51
AB52 AB52
AB55 AB55
AB56 AB56
AL01 AL1
AL02 AL2
AL03 AL3
AL04 AL4
How can I compare the first 3 or 4 letters of the postcode in the Locations
table to the corresponding entry in the Brick Codes table so I can add it to
my report?

Thanks for your help
Jul 20 '05 #1
2 3661
"Shaun" <no****@nospam. com> wrote in message
news:YL******** ***********@sto nes.force9.net. ..
Hi,

I have a table of Locations around the country. My system produces reports
based on these Locations. I also have a table containing Brick Codes e.g.

Brick Post Code
AB51 AB51
AB52 AB52
AB55 AB55
AB56 AB56
AL01 AL1
AL02 AL2
AL03 AL3
AL04 AL4
How can I compare the first 3 or 4 letters of the postcode in the Locations table to the corresponding entry in the Brick Codes table so I can add it to my report?

Use the substring function to get the n letters and the case
function to compare, such as ...

case when substring(brick ,1,2) = substring([post code],1,2) then 'matching
1st 2' else 'no match' end "Comparison 1 of x",
case when substring(brick ,1,3) = substring([post code],1,3) then 'matching
1st 3' else 'no match' end "Comparison 2 of x",
case when substring(brick ,1,4) = substring([post code],1,4) then 'matching
1st 4' else 'no match' end "Comparison 3 of x",
etc

Jul 20 '05 #2
Shaun,

This is untested, but should do the trick.

WHERE Brick = CASE LEN(PostCode)
WHEN 3 THEN STUFF(PostCode, 3,0,'0')
ELSE PostCode END

or

WHERE PostCode = CASE SUBSTRING(Brick ,3,1)
WHEN '0' THEN STUFF(Brick,3,1 ,'')
ELSE Brick END
Hope that helps,
Rich
"Shaun" <no****@nospam. com> wrote in message
news:YL******** ***********@sto nes.force9.net. ..
Hi,

I have a table of Locations around the country. My system produces reports
based on these Locations. I also have a table containing Brick Codes e.g.

Brick Post Code
AB51 AB51
AB52 AB52
AB55 AB55
AB56 AB56
AL01 AL1
AL02 AL2
AL03 AL3
AL04 AL4
How can I compare the first 3 or 4 letters of the postcode in the Locations table to the corresponding entry in the Brick Codes table so I can add it to my report?

Thanks for your help

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3566
by: Shane Groff | last post by:
I know this is a recurring discussion (I've spent the last 3 days reading through threads on the topic), but I feel compelled to start it up again. After reading through the existing threads, I find myself convinced that exceptions are a better mechanism, for example because constructors and operators can't return errors, and code that...
6
1892
by: Josh Mcfarlane | last post by:
I keep trying to get myself out of the return-code mindset, but it doesn't seem to work. They are suppose to get rid of if-then statements of return codes, but you still have to do an if statement once the code leaves your control (3rd party libraries, OS functions, etc) to throw an exception? Does anyone have any good suggestions on a book...
2
1655
by: Shaun | last post by:
Hi, I have a table of Locations around the country. My system produces reports based on these Locations. I also have a table containing Brick Codes e.g. Brick Post Code AB51 AB51 AB52 AB52 AB55 AB55 AB56 AB56
18
7160
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2 AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2...
3
2351
by: c# beginner | last post by:
we are trying to standardize return codes across our .NET applications (that are soon to be developed.) What is the best practice for standardizing return codes? I know of only the following option. Creating a class library that will contain the return codes (which will be static strings). Calling the return codes from this library across...
6
2573
by: normunds | last post by:
hi! I'm newbie in css and I can't make myself brick boxes that work in IE and Firefox. The problem is in brick size and layout. Can anybody put there code, how to make such wall without absolute positioning? Boxes should be with borders and with widths (different for each but pointed with width parameter). Height of boxes are equal. In one row...
3
1380
by: PerlPhi | last post by:
hi! i have a Perl code in here that when ran the program accepts any Perl codes from the user input (<STDIN>, of course use no syntax errors), then after breaking the multiline input, the inputs will be part of the program codes and well executed simoultaneously after breaking the multiline input. my novice codes as follows: #!/perl/bin/perl...
5
13468
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum pros: type safe. better for debug (some debugger will show the name not only the value) cons: enum can not be forward declared which makes all error codes
0
7626
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7591
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7911
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6180
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1161
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.