user5473546
user5473546

Reputation: 31

like command in sql query

I have a column that contains the value: "Mandatory info on model l_90 with features games_14. Please provide the info for this model.[server=stack3_112] "

i want to run only the first part, "Mandatory info on model l_90 with features games_14" and exclude "Please provide info for this model" from the result.

I tried

model like '% Mandatory info on model l_90 with features games_14%'

in the select but it didn't give me what I wanted.

Upvotes: 0

Views: 54

Answers (3)

drzounds
drzounds

Reputation: 379

WHERE {column name} like '% Mandatory info on model I_90 with features games_14%
AND {column name} NOT LIKE '%Please%')

Could this work?

This way any text that contains 'please' should be filtered out

Upvotes: 1

danjuggler
danjuggler

Reputation: 1320

I believe you are asking how to have only part of this column returned in your query. See:

select substr(your_column, 1, INSTR(your_column, 'Please'))
  from table
where your_column like '%Mandatory info on model l_90 with features games_14%' 

This will give you a substring of everything up until the first point it finds "Please".

Note: I'm not sure what dbms you are on but the above select will work in Oracle.

Upvotes: 1

Serif Emek
Serif Emek

Reputation: 674

select 'Mandatory info on model l_90 with features games_14'
from table
where column like '%Mandatory info on model l_90 with features games_14%' 

Upvotes: 0

Related Questions