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 8978653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:40:00+00:00 2026-06-15T19:40:00+00:00

Apologies if the title does not accurately describe the question (which it probably doesn’t).

  • 0

Apologies if the title does not accurately describe the question (which it probably doesn’t). I have the following two tables :-

tLiveTable:

PieceID      LocationRef
------------------------
100              5

tPieceTable:

ID    BatchNo      PieceNumber
------------------------------
50    ABC          X1
100   ABC          X1

How can I update the LocationRef for that piece in tLiveTable given only the BatchNo and PieceNo?

I’ve tried the following:

UPDATE tLiveTable
SET LocationRef = 'blabla unimportant'
WHERE
PieceID = (SELECT ID FROM tPieceTable WHERE (BatchNo = 'ABC') AND (PieceNo = 'X1'))

But there can be multiple entries in tPieceTable with an identical BatchNo and PieceNo. I want to only retrieve the ID from tPieceTable whose ID is currently the one in the tLiveTable.

Should I really be using an INNER JOIN for 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-06-15T19:40:01+00:00Added an answer on June 15, 2026 at 7:40 pm

    Your query will not work as SELECT ID FROM tPieceTable WHERE (BatchNo = 'ABC') AND (PieceNo = 'X1') returns more than one ID

    Try this;

    UPDATE L SET LocationRef = 'blabla unimportant'
    FROM tLiveTable L JOIN tPieceTable P 
         ON L.PieceID = P.ID
    WHERE (P.BatchNo = 'ABC') AND (P.PieceNo = 'X1')
    

    Or using IN for =

    UPDATE tLiveTable
    SET LocationRef = 'blabla unimportant'
    WHERE
    PieceID IN (SELECT ID FROM tPieceTable WHERE (BatchNo = 'ABC') AND (PieceNo = 'X1'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[Apologies if my question title does not accurately describe my problem- if you can
Apologies for the poor question title. I have two tables, jobs and Persons-Jobs. Jobs
Apologies if the title is vague, but it's not the easiest question to describe.
Apologies for the poor question title - I'm not sure how to describe what
My apologies if my title is not descriptive enough, I believe the following will
Firstly, apologies for the bad question title - not entirely sure if I am
I could not think of a better way to title this question. my apologies
(Apologies for the title of this question - I wasn't overly sure how to
My apologies for an inaccurate title, but I'm not sure what this is called
First: apologies for the question title, I don't actually know what the problem is

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.