473,785 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert nickname to fullname when querying data

52 New Member
I have a table of providers that has a license number and fullname field, among others. Deman helped me with being able to enter a nickname and having it change to the fullname if a nickname exists in a nickname table when I have new entries. I also have a table called TA where I enter requests, linking to the providers table with the license number. (The fullname field exists only in the providers table.) I'd like to be able to query the TA table for requests by entering the nickname (as it exists in the nickname table) rather than entering the fullname. Can anyone help? Thanks in advance.
May 23 '07 #1
13 3336
NeoPa
32,578 Recognized Expert Moderator MVP
You should be able to do this in a query after linking the tables in the relevant way. Your question is not currently clear enough to provide a direct answer.
If you post the table Meta-Data we can probably get you further with this.
Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
You will need to post (in this format please) for all the tables that link the data you need together.
May 25 '07 #2
CindySue
52 New Member
I'm sorry, I'm pretty much a novice. I'm not sure I understand about Meta-data. Is this it?

I have three tables, by the way:

Table Name=[Licensed Providers]
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. License No;Text;PK
  3. Admin Agency;Text
  4. and some other fields
Table Name = Nicknames
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. Nickname;Text;PK
  3. Admin Agency;Text
  4. these are the only two fields
Table Name = TA
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. License No;Text (this is the same as the Providers table)
  3. and some other fields.
I've created several entries in the nicknames table where I have a short abbreviation in the nickname field and then the full name in the Admin Agency field. For example, doe for the nickname and Department of Education for the Admin Agency field.

When I enter a new Licensed Provider, I can either enter the full name in the Admin Agency field or an abbreviation (or nickname) and if an entry exists for that nickname in the nicknames table it will change that entry to the full name, or leave it as typed if one doesn't exist. I'd like to be able to use this same thing in a query.

My query has both the Providers table and TA table, linked by the license number field. I can enter a part of the Admin Agency name (such as dep or edu) and it will look up records where the Department of Education is the Admin Agency. I would like to be able to enter either a part of the Admin Agency name or the nickname as it exists in the nickname table and find records. If it would be easier to have an extra field in the query that would be OK. I'll know ahead of time whether I want to look up by partial name or nickname, so if it would be easier to do with two separate queries, that would be fine.

Does that make more sense? Thanks so much. I really appreciate the help.
May 25 '07 #3
NeoPa
32,578 Recognized Expert Moderator MVP
It does (sort of) make sense.
My confusion now is how you're typing in a search string. You talk of running a (presumably SELECT) query, but there's no mention of a form or other such method of filtering or searching.
The SQL can be created for linking in the NickName stuff, but I'd need a better understanding of what you're doing with it to know what to suggest.
A good start would be to post the SQL of your current query. Please DO use the [code] tags (#) provided. It saves me the job of adding them for you afterwards ;)
May 25 '07 #4
CindySue
52 New Member
Here's my query code: ( I hope this is what you mean by code tags)

Expand|Select|Wrap|Line Numbers
  1. SELECT TA.[License No],
  2.        [Licensed Providers].[Admin Agency],
  3.        TA.[Type TA],
  4.        TA.Consultant,
  5.        TA.[Date Received],
  6.        TA.[Date to RC],
  7.        TA.[Date Assigned],
  8.        TA.[Reason 1],
  9.        TA.[Reason 2],
  10.        TA.[Date Scheduled],
  11.        TA.[Date Completed],
  12.        TA.[Requested By CCLS],
  13.        TA.[Sent to CCLS],
  14.        TA.Comments
  15. FROM [Licensed Providers] INNER JOIN TA
  16.   ON [Licensed Providers].[License No] = TA.[License No]
  17. WHERE ((([Licensed Providers].[Admin Agency]) Like "*" & [Enter Partial Admin Agency Name] & "*")
  18.   AND  ((TA.[Date Completed]) Is Null));
I've got a form that is attached to the query.

I'm opening the form, which in turn starts the query which asks me to enter a partial agency name. When I do that, the records are displayed in the form. Thanks for helping me. I realize I'm terribly inadequate in providing the information in the proper form.
May 25 '07 #5
NeoPa
32,578 Recognized Expert Moderator MVP
To add [code] tags to your post, simply select all the text that is code, then click on the graphic above the message you're typing, which looks like a hash (#). This will put [code] tags around the selected text for you. I fixed your last post for you, don't worry.

I will have to look at your question again later in the weekend as it's after 23:00 here atm and I'm getting tired.
May 25 '07 #6
NeoPa
32,578 Recognized Expert Moderator MVP
First lets deal with tidying up some things to make life easier for ourselves.
I've simplified usage of the [Licensed Providers] table with a pseudonym LP. This makes it easier to work with and understand at a glance. I assume that your table MetaData is the incorrect version and that the actual name of the [Providers] table is [Licensed Providers]. I've edited your post to reflect this.
I've changed the strings to use the more correct quote (') within SQL.
Expand|Select|Wrap|Line Numbers
  1. SELECT TA.[License No],
  2.        LP.[Admin Agency],
  3.        TA.[Type TA],
  4.        TA.Consultant,
  5.        TA.[Date Received],
  6.        TA.[Date to RC],
  7.        TA.[Date Assigned],
  8.        TA.[Reason 1],
  9.        TA.[Reason 2],
  10.        TA.[Date Scheduled],
  11.        TA.[Date Completed],
  12.        TA.[Requested By CCLS],
  13.        TA.[Sent to CCLS],
  14.        TA.Comments
  15. FROM ([Licensed Providers] AS LP
  16.      INNER JOIN TA
  17.   ON LP.[License No]=TA.[License No])
  18.      INNER JOIN NickNames AS NN
  19.   ON LP.[Admin Agency]=NN.[Admin Agency]
  20. WHERE ((TA.[Date Completed]) Is Null)
  21.   AND  ((LP.[Admin Agency] Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*')
  22.    OR   (NN.Nickname Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*'));
Now to the changes more relevant to your particular issue :
First of all you need to link in the extra table (See the FROM clause).
Now you need to change the WHERE clause to include a check for the Nickname. This should be ORed with the other name check, but together these checks should be ANDed with the date check.

I have made the assumption here that all [Admin Agency]s have associated Nicknames. If that is not true then this will not work as expected and some further changes will be required.
May 26 '07 #7
CindySue
52 New Member
Thanks so very much for your help. The Admin Agencies do not all have nicknames. Nicknames only exist for some of the longer ones or the ones most frequently used.
May 29 '07 #8
NeoPa
32,578 Recognized Expert Moderator MVP
Thanks so very much for your help. The Admin Agencies do not all have nicknames. Nicknames only exist for some of the longer ones or the ones most frequently used.
OK, but I'll have to come back to this tomorrow (or later today if I'm lucky).
If I haven't replied by tomorrow morning, then bumb the thread to re-add it to my list for tomorrow.
For future reference, that would have been handy to know before-hand ;)
May 29 '07 #9
NeoPa
32,578 Recognized Expert Moderator MVP
Thanks so very much for your help. The Admin Agencies do not all have nicknames. Nicknames only exist for some of the longer ones or the ones most frequently used.
The JOIN is changed and the Nz() function is used to handle unwanted Nulls.
Expand|Select|Wrap|Line Numbers
  1. SELECT TA.[License No],
  2.        LP.[Admin Agency],
  3.        TA.[Type TA],
  4.        TA.Consultant,
  5.        TA.[Date Received],
  6.        TA.[Date to RC],
  7.        TA.[Date Assigned],
  8.        TA.[Reason 1],
  9.        TA.[Reason 2],
  10.        TA.[Date Scheduled],
  11.        TA.[Date Completed],
  12.        TA.[Requested By CCLS],
  13.        TA.[Sent to CCLS],
  14.        TA.Comments
  15. FROM ([Licensed Providers] AS LP
  16.      INNER JOIN TA
  17.   ON LP.[License No]=TA.[License No])
  18.      LEFT JOIN NickNames AS NN
  19.   ON LP.[Admin Agency]=NN.[Admin Agency]
  20. WHERE ((TA.[Date Completed]) Is Null)
  21.   AND  ((LP.[Admin Agency] Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*')
  22.    OR   (Nz(NN.Nickname,'') Like '*' & [Enter Partial Admin Agency Name (or NickName)] & '*'));
May 30 '07 #10

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

Similar topics

11
3818
by: jguilford | last post by:
I have created a SQL Stored Procedure that uses a Case statement to determine the Order By. For one of the Case statements I am trying to turn a Char field into Datetime in for the Order By, however I can not get it to work. Can someone please take a look and my code below and tell me what I am doing wrong. Thank you. ORDER BY CASE WHEN @SortBy = 'dttm_stamp' THEN dttm_stamp End, CASE WHEN @SortBy = 'Event_Date1' THEN...
0
1814
by: aj | last post by:
DB2 WSE LUW 8.1 Fixpak 5 Red Hat AS 2.1 I'm trying to set up a federated view from one DB2 database to another in the same instance on the same server. I do a: create server <SERVER> type DB2/UDB version 8.1 wrapper DRDA authorization <INSTANCE_OWNER> password "<PASSWD>" options (NODE 'LOCAL',DBNAME '<DBNAME>',FOLD_ID 'N',FOLD_PW 'N')
9
2071
by: Kurt | last post by:
Hi I was trying to get this VB type code to work in C Sub SetColumns_Example( Dim ol As Outlook.Applicatio Dim MyFolder As MAPIFolde Dim itms As Item Dim itm As Objec Dim dtmStart As Date, dtmEnd As Dat Dim lngElapsed As Lon Set ol = New Outlook.Applicatio
5
15801
by: Jiggaz | last post by:
Hi, Look my stored procedure : __________________ ALTER PROCEDURE dbo.CreateAccount @Nickname varchar(30), @Password varchar(15), @Email varchar(50), @Date datetime,
1
2308
by: Mark Hollander | last post by:
Hi All, Could you please help me convert this code so that it will run in VB.NET Thank You Mark Hollander Private Type USER_INFO Name As String
3
7669
by: Jean-Marc Blaise | last post by:
Hi, Is there any reason why a CREATE NICKNAME statement fails if the remote object is an ALIAS ? I actually have an ALIAS that is used to point to the correct table in the remote DB, and would like the nickname to point to this alias, avoiding the obligation to drop and recreate the nickname any time. Thanks for your help,
7
3246
by: Arun Srinivasan | last post by:
I have a problem, I am getting SQL1042N The SQL statement is not supported. error when I try to create a MQT against a nickname. The source db is db2 version 9.1 fixpack 4, same as the target db and so the SQL is definitely supported and both are in windows 2003 server. Is there a way I could find why this error pops up. My syntax is like create mqt1 as (select col1, col2, ..............., colN from nickname where <predicate>) data...
4
3211
by: Arun Srinivasan | last post by:
I need to create an MQT on a nickname, the requirement is that I need to transfer data from source to target when required (this is because the nickname is slow - i can't implement required indices on the source table - tooo large). So when I tried create table table1 as (select * from nickname) data initially deferred refresh deferred; it returned sql0142N error - sql statement not supported. Both source and target dbs are db2 version...
9
35855
by: myotheraccount | last post by:
Hello, Is there a way to convert a DataRow to a StringArray, without looping through all of the items of the DataRow? Basically, I'm trying to get the results of a query and put them into a listbox. Right now it is done like this:
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7502
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
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 we have to send another system
2
3655
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.