52

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
  • 535
  • 1
  • 4
  • 6

1 Answers1

89

You can do this

WHERE SRV_NAME LIKE 'AA%'
rs.
  • 26,707
  • 12
  • 68
  • 90
  • Thanks! I figured it was something simple like this but I wasn't finding straight forward answers online. This worked like a charm! Thanks again! – Wuz Jul 20 '12 at 20:28
  • 4
    Beware that `LIKE` honors special chars `_` and `%` that may need to be escaped: https://stackoverflow.com/questions/21380261/underscore-is-not-working-in-oracle-like-clause – Vadzim Apr 27 '18 at 17:16