Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I query for something that starts with certain characters?

Tags:

sql

search

oracle

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.

like image 862
Wuz Avatar asked Jul 20 '12 20:07

Wuz


People also ask

How do I find start with in SQL?

ssll If you want to match the start of the string you should use 'ss%' instead. select * from table_name where column_name line 'ss%'; this query will return only ssll.

How do you select a name starting with a vowel in SQL?

To check if a name begins ends with a vowel we use the string functions to pick the first and last characters and check if they were matching with vowels using in where the condition of the query. We use the LEFT() and RIGHT() functions of the string in SQL to check the first and last characters.


1 Answers

You can do this

WHERE SRV_NAME LIKE 'AA%' 
like image 127
rs. Avatar answered Oct 08 '22 15:10

rs.