473,397 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Trouble flipping name field in query!!!!

Hello I'm new to queries!

I'm having a problem writing an update query that will look at a name field ie (Dan Wilson Sr) and flip the name to a shortname ie (Wilson Sr Dan) with the criteria based to only flip the name if it contains Jr or Sr.
Below is an example of a select query I was using to test before updating my table.

SELECT *
FROM [Goodrec - All]
WHERE (instr(shortname,' JR')>0 Or instr(shortname,'SR')>0 Or instr(shortname,' III')>0) And instr(shortname,' MD')=0;

This query provides the following result for example, if name is "PAUL D TAYLOR SR" it is flipped to "SR PAUL D TAYLOR." I need shortname to display it like this "TAYLOR SR PAUL D"

Thanks in advance for any assistance!
Oct 9 '07 #1
2 1620
nico5038
3,080 Expert 2GB
Hello I'm new to queries!

I'm having a problem writing an update query that will look at a name field ie (Dan Wilson Sr) and flip the name to a shortname ie (Wilson Sr Dan) with the criteria based to only flip the name if it contains Jr or Sr.
Below is an example of a select query I was using to test before updating my table.

SELECT *
FROM [Goodrec - All]
WHERE (instr(shortname,' JR')>0 Or instr(shortname,'SR')>0 Or instr(shortname,' III')>0) And instr(shortname,' MD')=0;

This query provides the following result for example, if name is "PAUL D TAYLOR SR" it is flipped to "SR PAUL D TAYLOR." I need shortname to display it like this "TAYLOR SR PAUL D"

Thanks in advance for any assistance!

The select query certainly won't produce the needed result.
It's even questionable or you'll ever get this to work flawlessly as there are too many possibilities to write a name (including typo's) and I stopped trying to create 100% automated changes to names that were entered fully in one field.
I switched to doing 80% of the obvious changes by code and leave the remainder to people to do it manually.
Normally I would only process the names having two words and save them in separate fields (Firstname and LastName). For Prefix and Suffix and MiddleInitial I would create fields and have them filled from a form where people can select part of the text in the original name and the selected text will be transported to the correct target fields. Having these fields I would re-construct the name in the way needed for reporting.

Getting the idea ?

Nic;o)
Oct 10 '07 #2
missinglinq
3,532 Expert 2GB
I actually enjoy working on this kind of problem, but as nic;o) indicated, trying to parse things like names with Jr, Sr, III and so forth on the end generally turns into a mare's nest! So before we get any deeper into this, I'd like to check a statement you made.
flip the name to a shortname ie (Wilson Sr Dan) with the criteria... only flip the name if it contains Jr or Sr.
Are you saying that you only want to do this if your original field ends in Jr or Sr, or do you want to flip all names? If all names, what titles beside Jr and Sr do you want to take into account? It's easier to write code correctly the first time than to go back and modify it later.

Welcome to TheScripts!

Linq ;0)>
Oct 10 '07 #3

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

Similar topics

0
by: dvorett | last post by:
I know this topic has been discussed a lot but after going through the old posts, I'm still having trouble with the code. I have a photo name field which refers to the location of the photo on the...
14
by: Larry R Harrison Jr | last post by:
I have designed databases but have never come across any complications due to the ridiculous situation of a hyphenated last name. As a database designer (very junior level) I disdain anything...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
2
by: billy001 | last post by:
How do I go about grabbing only the last name out of a 'Full Name' field ? I've so far tried executing a parse script in Oracle 9i using SQL Plus and am not successfully getting any data returned. ...
2
by: CollierC | last post by:
I need to write a query that manipulates a name field from "firstname lastname" to "lastname, firstname". I have read multiple solutions to split firstname and lastname to separate fields,...
4
by: NeilIanBaker | last post by:
Hello I am trying to select the first name and surname from a name field where the name is in the form of; eg. Mrs Marilyn Payne Mrs Mary Swanton Ms EM Lomas Lt Col R...
4
by: princelindie | last post by:
I am using code that looks something like this: <?php mysql_connect("localhost", "xxxx_xx", "xxx") or die(mysql_error()); mysql_select_db("xxxx_xxx") or die(mysql_error()); $query="SELECT...
2
by: dynamo | last post by:
it seems to me that when the name field of an input in a form has an entry with a dot in it,it changes the dot to a dash on submitting it.Is there anyway to get over this problem.Thanks for any...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.