sql - Replace function in MySQL using values from another table -
i have 2 tables: animals , names.
the animal table has:
- id
- age
- type
- habitat
- description including name
while names table has:
- name
- alias
is there way create mysql query searches name in animal table, locates it, replaces relative alias using alias's column?
i know how use replace() function using set string, not sure how incorporate loop function check more 1 string in column.
edit: know updating fk bad idea may have suggested. idea can find substring, within description column , replace corresponding value in 'names' table. 'names' table act kv stance replace name (in description) alias.
sample object (json):
{ "animal" : { "id" : 1, "age" : 20, "type" : "zebra", "habitat" : "safari", "description" : "our zebra, zoe, loves run , play day" } } { "names" : { "name" : "zoe", "alias" : "equus quagga" } }
the idea create mysql query replace 'zoe' 'otherwise known equus quagga' in description field, every animal , related alias.
Comments
Post a Comment