Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Matching Multiple Parts of Search String To a Column.

mlov83Jun 4 2019 — edited Jun 5 2019

table ddl:

CREATE TABLE bldg_table (

    building_code   VARCHAR2(100),

    building_desc   VARCHAR2(600)

);

Table Data:

INSERT INTO BLDG_TABLE (BUILDING_CODE, BUILDING_DESC) VALUES ('01', 'empire state building 824');

INSERT INTO BLDG_TABLE (BUILDING_CODE, BUILDING_DESC) VALUES ('02', 'empire state building 644');

I'm stuck in trying to write a query that would contain multiple parts of my description.

For example I would like to query my bldg_table and retrieve the column based on matching multiple parts of a given string.

so for example.

SELECT

    building_code,

    building_desc

FROM

    bldg_table

    where building_desc like ('%empire 824%');

This will not return building code 1

however this will

SELECT

    building_code,

    building_desc

FROM

    bldg_table

    where building_desc like ('%824%');

This is part of a much bigger application but the problem I'm trying to solve is simply match mutiple parts of the search string in order to retrieve a column and I'm failing miserably.

Can someone point me in the right direction?

This post has been answered by CarlosDLG on Jun 4 2019
Jump to Answer
Comments
Post Details
Added on Jun 4 2019
12 comments
6,397 views