this is the first time I'm posting here! Hope to get a good reply.
I have two table, and based on the path I need to locate and replace with '' the name of table2 in the name of table1.
table1
+---------------+----------+
| name | path |
+---------------+----------+
| John Smith | 12345 |
+---------------+----------+
| John Smith | 54321 |
+---------------+----------+
| JohnSmith | 12345 |
+---------------+----------+
table2
+---------------+----------+
| name | path |
+---------------+----------+
| John | 12345 |
+---------------+----------+
| Smith | 54321 |
+---------------+----------+
the final result would be like
+---------------+----------+
| name | path |
+---------------+----------+
| Smith | 12345 |
+---------------+----------+
| John | 54321 |
+---------------+----------+
| JohnSmith | 12345 |
+---------------+----------+
as you can see I need to replace only the exact match. So in JohnSmith I don't remove John.
The question is also, do I do it only with a mysql query? Or some php is also needed for something like that?
Thank you in advance.
both queries are close, but don't give exactly what I need as an output.
e.g. the first one produce
NAME PATH
Smith 12345
John 54321
Smith 12345
here the last row, should not be changes. As we don't have any exact match. and the row should stay the same "JohnSmith"
in the second one, the output is
NAME PATH
Smith 12345
John Smith 54321
JohnSmith 12345
here the second line seems wrong, as it should remove "Smith"
any idea ?