Click here to Skip to main content
15,891,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted
Updated 4-Jul-19 3:16am
Comments
Richard MacCutchan 4-Jul-19 7:59am    
Why are you saving the same information in two different tables?

1 solution

MySQL CONCAT_WS() Function[^]
The above MySQL function will allow you to build the result you want:
SQL
SELECT
 CONCAT_WS(" ", first_name, middle_name, last_name) AS FullName
FROM
 Table1
WHERE
 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[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900