473,473 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

displaying something else in results instead of value in DB

3 New Member
Hi,

I am retrieving State abbreviations from the database (e.g. CA, WA, TX). What I would like to do is that when any of the state abbreviations are encountered, I will display the full state name intead of the abbreviation.

What do I need in my statement to do this? I'm playing with IF statements with no success

e.g.
SELECT address, city, state
FROM atable
WHERE city like 'Culver%'


instead of seeing
address city state
555 Culver City CA

I would like to display
address city state
555 Culver City California


Tnx.
Mar 12 '07 #1
2 6196
bergy
89 New Member
If you have another table containing the definitions of the abbreviations you could do something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT atable.address, atable.city, abbrevtable.stateFull
  2. FROM atable
  3. INNER JOIN abbrevtable ON atable.state = abbrevtable.stateAbbrev
  4. WHERE atable.city LIKE 'Culver%'
That statement assumes you have a table called abbrevtable with an entry like this in it:
Expand|Select|Wrap|Line Numbers
  1. stateAbbrev            stateFull
  2. -----------            ---------
  3. CA                     California
Hi,

I am retrieving State abbreviations from the database (e.g. CA, WA, TX). What I would like to do is that when any of the state abbreviations are encountered, I will display the full state name intead of the abbreviation.

What do I need in my statement to do this? I'm playing with IF statements with no success

e.g.
SELECT address, city, state
FROM atable
WHERE city like 'Culver%'


instead of seeing
address city state
555 Culver City CA

I would like to display
address city state
555 Culver City California


Tnx.
Mar 13 '07 #2
mabubakarpk
62 New Member
If you have not any reference table then you can write this query

Expand|Select|Wrap|Line Numbers
  1.  
  2. select City,case City when 'NY' then 'NewYork'
  3.                             when 'LHR' then 'Lahore'
  4.                             else 'Not Defined'  end as CityFullName 
  5.                             from City
  6.  
  7.  
Mar 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Francisco | last post by:
I have this question: I have a simple search to a db, something like: "select description from games where year = '1990'" suppose I get 300 results, I would like to display this in pages of 30...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
2
by: poohbah | last post by:
Hi Everyone - I am very new to scripting. I got a formmail.asp file off the internet to set up a simple form on a contact us page, The problem is that the email addresses in the results emails are...
2
by: NasirMunir | last post by:
I have created a table in access (copied from excel). Then I created a form which contains a text field and a list box. The text field is actually a look-up field, where a user can enter a searchable...
10
by: ALKASER266 | last post by:
Hey guyz I have a prac and I am beginner and I did this code> Is my code is complete and if is it not complete how i can complete it? and how i can arrange it more? How I can make my driver to...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
1
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...
0
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,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.