user6657228
user6657228

Reputation:

Sql Update Query

UPDATE trainerdetails 
SET trainerdetails.login_code='100' 
WHERE trainerdetails.empname=admin.[name]

This is my Sql Syntax I want to update login_code. I have two tables

  1. for Admin

  2. for all user including admin

I just want to give the login code to multiple type of user(eg admin='100' employee='200') but this update query is not working. This is what the error I am facing:

The multi-part identifier "admin.name" could not be bound.

And select Query for same table is working

SELECT trainerdetails.tid
  ,trainerdetails.trid
  ,trainerdetails.login_code
  ,trainerdetails.empname 
FROM trainerdetails,admin 
WHERE trainerdetails.empname=admin.[name]

Upvotes: 0

Views: 82

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270993

This is the syntax in SQL Server:

update td
    set login_code = '100' 
    from trainderdetails td join
         admin a 
         on td.empname = a.[name];

Upvotes: 1

Related Questions