Home > Back-end >  Help: now there are two list, find the list is not in the list of data within a 2 in 1, two lists kn
Help: now there are two list, find the list is not in the list of data within a 2 in 1, two lists kn

Time:09-26

Help:
Now have two list, find out the list is not in the list of data within a 2 in 1, two lists known large amount of data. Listing 2 has according to the length of the string in reverse.
Listing 1. TXT
Beijing golden company
Beijing golden century company
Beijing gold company

Listing 2. TXT
Golden century
Golden

Requirement for the output results of
Beijing gold co.

CodePudding user response:

I am a little white, did this aspect of the business, I think can be combined with redis to do, the two table data is loaded into the redis set in the collection, use sdiff command to calculate difference set, can you?

CodePudding user response:

reference 1st floor QQVB response:
I am a little white, did this aspect of the business, I think can be combined with redis to do, the two table data is loaded into the redis set in the collection, use sdiff command to calculate difference set, can you?

Two in the list of characters is not the same, only know containment relationship. Not sure list 1 order.
If the two bag is the same string, sdiff or not can be implemented in the database.

CodePudding user response:

 with tab1 as (
Select '111' id from dual union all
Select '1121' id from dual union all
Select '1131' id from dual
),
Tab2 as (
Select '111' id from dual union all
Select '121' id from dual union all
Select '11331' id from dual
)
Select * from tab1 t1
Where not the exists (
Select 1 from tab2 t2 where instr (t1. Id, t2. Id) & gt; 0
)
;

CodePudding user response:

The
reference 3 floor nayi_224 response:
 with tab1 as (
Select '111' id from dual union all
Select '1121' id from dual union all
Select '1131' id from dual
),
Tab2 as (
Select '111' id from dual union all
Select '121' id from dual union all
Select '11331' id from dual
)
Select * from tab1 t1
Where not the exists (
Select 1 from tab2 t2 where instr (t1. Id, t2. Id) & gt; 0
)
;

I put the data change

Listing 1. TXT
Beijing golden company
Beijing golden century company
Beijing gold company

Listing 2. TXT
Golden century
Gold

Requirement for the output results of
Beijing golden co.

CodePudding user response:

reference 4 floor honey friend replies:
Quote: reference nayi_224 reply: 3/f

 with tab1 as (
Select '111' id from dual union all
Select '1121' id from dual union all
Select '1131' id from dual
),
Tab2 as (
Select '111' id from dual union all
Select '121' id from dual union all
Select '11331' id from dual
)
Select * from tab1 t1
Where not the exists (
Select 1 from tab2 t2 where instr (t1. Id, t2. Id) & gt; 0
)
;

I put the data change

Listing 1. TXT
Beijing golden company
Beijing golden century company
Beijing gold company

Listing 2. TXT
Golden century
Gold

Requirement for the output results of
Beijing golden company

Beijing golden company has gold, why output?

CodePudding user response:

For what upstairs in SQL, the original poster is needed is a TXT document to extract data, use the outputstream first read the file content, way of reading is read one line, read out the data as string, and then compare, specific methods can't write, you can check in this direction

CodePudding user response:

reference 5 floor nayi_224 reply:
Quote: refer to 4th floor honey friend replies:

Quote: refer to the third floor nayi_224 response:

 with tab1 as (
Select '111' id from dual union all
Select '1121' id from dual union all
Select '1131' id from dual
),
Tab2 as (
Select '111' id from dual union all
Select '121' id from dual union all
Select '11331' id from dual
)
Select * from tab1 t1
Where not the exists (
Select 1 from tab2 t2 where instr (t1. Id, t2. Id) & gt; 0
)
;

I put the data change

Listing 1. TXT
Beijing golden company
Beijing golden century company
Beijing gold company

Listing 2. TXT
Golden century
Gold

Requirement for the output results of
Beijing golden company

Beijing golden company has gold, why output?
assume that listing 2 is the size of the company, not in the listing 2 requires output

CodePudding user response:

refer to 6th floor dhacker1 response:
for what upstairs in SQL, the original poster is needed is a TXT document to extract data, use the outputstream first read the file content, way of reading is read one line, read out the data as string, and then compare, specific methods can't write, you can check in this direction under the
doesn't matter what language, but certainly cannot use simple contains to deal with

CodePudding user response:

Look at the KMP algorithm

CodePudding user response:

In the name of the company law, first on the list go to the head to tail, and then list with two matches?
  • Related