Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:50:50+00:00 2026-05-24T02:50:50+00:00

This seems really straight forward, and I think I just want to validate and

  • 0

This seems really straight forward, and I think I just want to validate and ensure that I’m doing this correctly.

Basically I want to run an UPDATE on these records:

SELECT     contact.company, contact.coaddress, contact.costate, contact.cocity, contact.cozip, contact.phonebusiness, dial.AgentID, dial.Attempts, dial.CRC
FROM         contact LEFT OUTER JOIN
                  dial ON contact.DialID = dial.DialID
WHERE     (dial.AgentID > '-1') AND (contact.cozip LIKE '600%' OR
                  contact.cozip LIKE '601%' OR
                  contact.cozip LIKE '606%' OR
                  contact.cozip LIKE '608%' OR
                  contact.cozip LIKE '605%' OR
                  contact.cozip LIKE '604%' OR
                  contact.cozip LIKE '613%' OR
                  contact.cozip LIKE '611%')

I get back my correct results on the SELECT statement. I need to now UPDATE those records:

UPDATE    dial
SET              ProjectID = '60'
FROM         dial INNER JOIN
                  contact ON dial.DialID = contact.DialID
WHERE     (dial.AgentID > '-1') AND (contact.cozip LIKE '600%' OR
                  contact.cozip LIKE '601%' OR
                  contact.cozip LIKE '606%' OR
                  contact.cozip LIKE '608%' OR
                  contact.cozip LIKE '605%' OR
                  contact.cozip LIKE '604%' OR
                  contact.cozip LIKE '613%' OR
                  contact.cozip LIKE '611%')

Does this look correct? Is there a more efficient way of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:50:52+00:00Added an answer on May 24, 2026 at 2:50 am

    Yes, this looks correct.

    There are some LIKE tricks and I like aliases personally. The alias d makes it clear which table is being updated in the JOIN. The [] in the LIKE means a range or set

    UPDATE
        d
    SET 
        ProjectID = '60'
    FROM
        dial d
        INNER JOIN
        contact ON d.DialID = contact.DialID
    WHERE
       (d.AgentID > -1) --edit, int. Not varchar
       AND 
       (contact.cozip LIKE '60[016854]%' OR contact.cozip LIKE '61[13]%')
    

    Should AgentID be the number -1 too?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like it should be really straight forward. if I have: object obj
This seems really dumb. I've tried a bunch of different ways and it's just
This seems straight forward enough , but i have not been able to identify
This seems really easy (I've done it a million times and never had a
This seems really strange to me: f = File.open(Dir.pwd+'/tmp','r') f.readlines do |l| puts #{f.lineno}:#{l}
After ages of programming in php this question seems really weird still to me.
This really seems like a bug to me, but perhaps some databinding gurus can
Ok, so this seems like a really silly problem but I can't get my
This seems like it should be really simple, but I'm unable to figure this
This seems like it should be really easy but I couln't find an answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.