简体   繁体   中英

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.

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

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.

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%' 

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