简体   繁体   中英

SQL Command to find a string value that ends in 'Z

I need to search a table to find Job Codes that end in 'Z'. What would the SQL command look like?

Select Job Code
From <table>
Where Job Code contains ????

Like will be what you need. It allows you to do wildcard searches over a column.

Select [Job Code]
From <table>
Where [Job Code] like '%Z'

% is your wildcard, so %Z will find every job code that ends with Z

%Z% will find every job code that has Z in it, and Z% if you want it to start with Z

Depending on your platform _ (underscore) can also be used as a wildcard for a single letter. If you wanted to find only two character job codes that ended with z it would be like '_Z'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM