Click here to Skip to main content
14,383,593 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have two tables where the first table contain the employee id, first_name, middle_name and last_name. in the second table i have employee_id and employee_name. so second table have php page hwere it shows the employee_id and employee_name tag, so if i selec the employee_id in this it must show the employee_name which was combination of first_name + middle_name + last_name from first table.I need the mysql query for this . I am beginner in this so can anyone help to me solve this issue ?

What I have tried:

to write a mysql query to shows the employee full name from another table and display in php form.
Updated 4-Jul-19 4:16am
Richard MacCutchan 4-Jul-19 7:59am
Why are you saving the same information in two different tables?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

MySQL CONCAT_WS() Function[^]
The above MySQL function will allow you to build the result you want:
 CONCAT_WS(" ", first_name, middle_name, last_name) AS FullName
 id=(some user id);

About the way to fetch and display the result in php, you just have to search for examples here on CP, or with your favorite search engine. Some examples:
php form prepared statement[^]
PHP - Code Project[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100