movie_table
id movie_name genre rating
1 Green lantern action 7.5
2 Seven horror 8.5
4 django comedy 6.0
tv_serial
id serial_name genre rating
1 game of throne action 9.5
2 walking dead horror 8.5
4 breaking bad comedy 6.0
Now if I put any name starting with G in the search bar the list must show green lantern and game of throne. Just need the sql query to extract these data thank you.
Edit
To sound more generalized and to be helpful for others, this question is rephrased as: How to implement Trie in php where data is obtained from a mysql table?
Try following query :
SELECT movie_name as Name
FROM movie_table
WHERE movie_name like 'G%'
union all
SELECT serial_name as Name
FROM tv_serial
WHERE serial_name like 'G%'