How do I query for something that starts with certain characters?
101,020
You can do this
WHERE SRV_NAME LIKE 'AA%'
Author by
Wuz
Updated on July 09, 2022Comments
-
Wuz almost 2 years
Here is my code:
SELECT SRV_NAME, TOT_CPU, TOT_MEM, SNAP_DATE FROM capacity.SRV_CAPACITY_SEV WHERE SRV_NAME in ('absshs1p", "AA03server', 'AA02server', 'BA01server', 'BA03server', 'BC03server') AND SNAP_DATE BETWEEN to_date('10-jun-2012 00:00:00', 'dd-mon-yyyy hh24:mi:ss') AND to_date('12-jun-2012 00:00:00', 'dd-mon-yyyy hh24:mi:ss') ORDER BY SRV_NAME desc, SNAP_DATE desc;
How would I query for servers that begin with certain characters? For example, how could I serach for servers that only begin with 'AA'?
I am using Oracle SQL btw.
-
Wuz almost 12 yearsThanks! I figured it was something simple like this but I wasn't finding straight forward answers online. This worked like a charm! Thanks again!
-
Vadzim about 6 yearsBeware that
LIKE
honors special chars_
and%
that may need to be escaped: stackoverflow.com/questions/21380261/…