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

  • SEARCH
  • Home
  • 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 8948829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:05:38+00:00 2026-06-15T13:05:38+00:00

I have looked at SQL update query using joins ..but it is not exactly

  • 0

I have looked at
SQL update query using joins
..but it is not exactly what I need (I am used to cook-book SQL, and can’t figure out how to modify the answers).

I have a table “a” and a table “b”. I want to update field f1 in “a” if and only if “b” has a record with fields f1, f2, f3 equal to f1, f2, f3 in table “a”.

So, if I have

TABLE a
f1            f2            f3         ...
------------------------------------------
m             a1a 1a1       1-1-1980
m             a1a 1a1       1-1-1980
m             b1b 1b1       18-1-1982
m             c1c 1c1       16-4-1975

TABLE b
f1            f2            f3         ...
------------------------------------------
m             b1b 1b1       18-1-1982
m             c1c 1c1       16-4-1975

Do update. Then Table “a” looks like:

TABLE a
f1            f2            f3         ...
------------------------------------------
m             a1a 1a1       1-1-1980
m             a1a 1a1       1-1-1980
m             b1b 1b1       *-1-1982
m             c1c 1c1       *-4-1975

I know how to do the string manipulation… but the update query is not something I’m used to, especially in this context. I would appreciate your help.

Thank you!

EDIT: I am using sqlite

EDIT 2: Here is a query that user suggested, but it is not working currently to update records (probably my mistake):

UPDATE diseases
SET dateofbirth='*'||ltrim(dateofbirth,0123456789)
WHERE gender=(SELECT a1.gender FROM diseases AS a1 
              INNER JOIN stage2helper AS b ON     a1.gender = b.gender AND 
a1.dateofbirth = b.dateofbirth AND a1.postalcode = b.postalcode) 

AND postalcode=(SELECT a1.postalcode FROM diseases AS a1 INNER JOIN stage2helper AS b   ON a1.gender = b.gender AND a1.dateofbirth = b.dateofbirth AND a1.postalcode = b.postalcode) 

AND dateofbirth=(SELECT a1.dateofbirth FROM diseases AS a1 INNER JOIN stage2helper AS     b ON a1.gender = b.gender AND a1.dateofbirth = b.dateofbirth AND a1.postalcode =     b.postalcode);
  • 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-06-15T13:05:39+00:00Added an answer on June 15, 2026 at 1:05 pm

    In Transact-SQL you can do this

    UPDATE a
    SET    a.f3=yourfunctiontogeneratetext()
    FROM   b
    WHERE  a.f1=b.f1 AND a.f2=b.f2 AND a.f3=b.f3
    

    Ok with ANSI SQL you can’t use the from syntax so try

    UPDATE a
    SET    a.f3=yourfunctiontogeneratetext()
    WHERE  a.f1 = (SELECT a1.f1
                   FROM a as a1
                        iNNER JOIN
                        b ON  a.f1=b.f1 AND a.f2=b.f2 AND a.f3=b.f3) and
           a.f2 = (SELECT a1.f2
                   FROM a as a1
                        iNNER JOIN
                        b ON  a.f1=b.f1 AND a.f2=b.f2 AND a.f3=b.f3) and
           a.f3 = (SELECT a1.f3
                   FROM a as a1
                        iNNER JOIN
                        b ON  a.f1=b.f1 AND a.f2=b.f2 AND a.f3=b.f3)
    

    I did this on a tablet so please forgive any typos

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

Sidebar

Related Questions

I have looked but have not found a specific answer for changing just one
I have looked thoroughly, but I have not found the solution (or perhaps I
I have never used triggers before in SQL server and I have looked around
Have looked quite hard for this answer but having no luck. I have 3
I have this idea that using SQL VIEWS to abstract simple database computations (such
Let me start by saying I have looked at many similar questions asked, but
Is there a SQL query I can run (or some other way) that will
I have looked at various example of the SQL Merge statement.. all of which
I'm using Entity Framework 5 on .NET 4.5 with SQL Server 2012. I have
I have a very simple question about transactions. (In sql server 2000, but I

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.