The exact answer depends on your DBMS, but will be similar to this Oracle solution:
1) Use the INSTR function to find the hyphen:
INSTR( zip_code, '-' )
This returns 6 in your example, and 0 if there is no hyphen
2) Use the SUBSTR function to get just the part before the hyphen:
SUBSTR(zip_code,1,5)
To neatly handle the case where the hyphen is absent, you could do this:
SELECT SUBSTR( zip_code, 1, INSTR( zip_code||'-', '-') - 1 )
FROM ...
I think INSTR may be called CONTAINS, and SUBSTR called SUBSTRING in SQL Server.