Sql query with Join

Hello Experts ,
Please find the file attached , how do I get the expected result.

Thanks
Example6.xlsx
RIASAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

irudykCommented:
This should do it
SELECT A.Code, A.Ref, A.Auth, B.Name, B.Surname
FROM TableA A INNER JOIN TableB B ON A.Code = B.Code

Open in new window

Answer_MeCommented:
SELECT B.CODE, A.REF,A.AUTH,B.NAME,B.SURNAME
FROM TABLEB B
LEFT JOIN TABLEA A ON B.CODE=A.CODE
pcelbaCommented:
MS SQL Server also allows older notation for table joins in FROM clause:
SELECT A.Code, A.Ref, A.Auth, B.Name, B.Surname
  FROM TableA A, TableB B 
 WHERE A.Code = B.Code

Open in new window

Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

pcelbaCommented:
But it seems you would need something different - UPDATE TableB rows by values from TableA:
DECLARE @TableA TABLE (Ref int, Auth char(3), Code char(5))
INSERT INTO @TableA VALUES (1, 'dfk', '45HJN'), (5, 'JOL', '78HJU')

DECLARE @TableB TABLE (Code char(5), Ref int, Auth char(3), Name varchar(20), Surname varchar(20))
INSERT INTO @TableB VALUES ('45HJN', null, null, 'Avc', 'hhuo'), ('78HJU', null, null, 'huo', 'uiu')

SELECT * FROM @TableB

UPDATE @TableB SET Ref = A.Ref, Auth = A.Auth
  FROM @TableB B
  JOIN @TableA A ON A.Code = B.Code

SELECT * FROM @TableB

Open in new window

Above example defines TableA and TableB in variables but you may use your own tables or temp tables.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Thanks!!!
slightwv (䄆 Netminder) Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SQL

From novice to tech pro — start learning today.