Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Oracle SQL, how can i use like operator in this way => like '%column name%'

I wanna search for certain data with the a certain pattern. But I would like to do it as an user-input function, search for the pattern that i put in.

with user_input as(
select 'user input' usr_ip
from dual
)

select
*
from table
where column like '%usr_ip%'

I wanna get the result dataset of the column containers usr_ip

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The following would generally work…

with user_input as( select 'user input' usr_ip from dual )
select * from someTable where someColumn like '%'||user_input.usr_ip||'%'

But if your real question is how to get user input into a sql statement, well, that is not something to be done in SQL. There is no SQL statement or function to get data from the user directly. Mechanisms like host variables or dynamic sql can be used in the calling program to provide user input to the database.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading