×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

I have somewhat of an odd situation

I have somewhat of an odd situation

I have somewhat of an odd situation

(OP)
I have somewhat of an odd situation.

I have a table titled working. In addition to many fields one contains a dealer ID. We want the dealer ID to be a number however sometimes a dealer enters their name instead of their dealer number. The service provider we use to manage this accepts either.

When we get a name instead of a number from our service provider the dealer ID will always start with “* “, that’s asterisk space then the dealer name.
For example, “* Dealer Name”.

We have a query that will select the distinct dealer names based on this criteria. The query inserts the dealer name in a table that has two fields, DelID and DealerID. We manually enter the dealer number in the DelID field.

INSERT INTO dealid ( dealerid )
SELECT DISTINCT (Working.dealerid)
FROM Working
WHERE left(dealerid,1) = chr(42);

Please note, in some cases a single dealer will have more than 100 individual entries in a single month.

Now, if next month we have a new dealer name entry we don’t want to recreate the DealID table, we only want to add the new dealer name to the DealID table. We will then manually add the dealer number for this new dealer name.

We have a query that changes the DealerID in the working table using the data in the DealID table.

UPDATE working INNER JOIN DealID ON [working].[dealerid] = [dealid].[dealerid] SET working.dealerid = [dealid].[delid]
WHERE [dealid].[dealerid] = [working].[dealerid];

We am struggling to write a query that will only add DealerID’s (dealer name) to the DealID table if the DealerID does not exist in the DealID table.

We want to continue to add to the DealID table as necessary and use this table to change the working.DealerID to the dealer number each month.

Any assistance is appreciated.

Ron--

RE: I have somewhat of an odd situation

"a query that will only add DealerID’s (dealer name) to the DealID table if the DealerID does not exist in the DealID table"

INSERT INTO dealid ( dealerid )
SELECT DISTINCT (Working.dealerid)
FROM Working
WHERE left(dealerid,1) = chr(42)
AND Working.dealerid NOT IN (Select dealerid from dealid)


---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close