how to output data with only an specific string on it

hi! i made an sql script but i do not know how to just output all the lines that starts with an specific string. and that string, you will input it before i run the sql

for example:

INPUT NAME: JOHN

i just want to output lines that starts with JOHN

your question is not clear

are you looking for grep command ?

 
grep "JOHN" filename 

It depends on the SQL engine you are using but something like the following works in the MySQL engine.

SELECT * FROM USERS WHERE (name like "JOHN%");

If however you want to filter the output of your script then simply piping the output through

grep -e '^JOHN' 

will do the trick