you should be thinking of a redesign, if you have to search for a fragment of a field.
These are the neverending queries, unless you have a different argument to cut the data down, or have small tables anyway.
but it is relatively easy:
$querystring = "SELECT * FROM $table_images".$pre_fix." WHERE parent_id like '%TEST_50%'";
Btw. If you think of security and performance, never do Select * - allways explicitely name the fileds you are selecting - and allways only select the fields, you want to work with, to keep response small.