how to update a column fname and lname from another table? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to update a column fname and lname from another table?

i have create a table emp with column name fullname and in second table emp1 with column name fname and lname i want update fname and lastname pls help to update fname and lastname suppose that in 1st table fullname is JACK DAWSON then i want to update in 2nd table fname =jack and lname= dawson how can i do this m confused

19th Dec 2016, 6:54 PM
SQL LOVER
SQL LOVER - avatar
4 Answers
+ 1
I am assuming that you have two tables and you are trying to update the second table: then simply: UPDATE empl SET fname='JACK' lname='DAWSON' This is doing so manually. However if you are talking about automatically updating the second table as soon as the first table is updated, then there needs to be some sort of scripting, like PHP.
19th Dec 2016, 7:45 PM
Ravi Garbuja Pun
Ravi Garbuja Pun - avatar
0
i want to update automatically with substring and charindex function not to manually this is a interview question for SQL developer profile
20th Dec 2016, 8:55 AM
SQL LOVER
SQL LOVER - avatar
0
i have 2 table in 1st table with column name fullname jack dawson and i want to update fullname in 2nd table with firstname and lastname
20th Dec 2016, 9:02 AM
SQL LOVER
SQL LOVER - avatar
0
$server='localhost'; $username='root'; $password=''; $dname='employee'; //maybe $conn=mysqli_connect($server, $username, $password, $dbname)$sql="SELECT fullname FROM emp where id=1" $result=mysqli_query($conn,$sql) now you have got the full name from your first table. separate it using a php function and then use insert into second table query
1st May 2017, 5:58 PM
Ravi Garbuja Pun
Ravi Garbuja Pun - avatar