Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do you get the first and last name from the ID?

So I am making a system for my work and I am struggling on figuring out how to take the Employee_ID and get the First and Last name of the employee and then take the first and last name and combine it to be just the full name.

I have already figured out how to convert first and last name to full name using

Create proc FullName
as
begin
select concat(concat(fname, ' '),lname) FullName
from Employees
end

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is an SQL-related question but since you are using concat, you can also select the field distinctly as shown above.

Whereas, adding the where clause limits your result to only the specified ID.

The question in the query is where your ID goes depending on which method you are using and the target DBMS

Create proc FullName @employeeId int
as
begin
select concat(concat(fname, ' '),lname) FullName, fname, lname
from Employees WHERE Employee_Id = @employeeId

end
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading