Home > database >  Mysql query
Mysql query

Time:09-20

Now there are two strings, such as
A string: 1 - A, 1 b, 2 A, 2 - c
String B: 12 - a, 23 B, 24 - c

After the commas:
A: 1 - A, 1 b, 2 - A, 2 - c four small string
B: 24-12 - a, 23 B, c 3 small string

Cycle comparison sheet at the back of the string is consistent, there are 12 - a, B in a 1 - a, because behind - are a, string in front of the comparison, 12 is 1 at the beginning, so 1 - a and 12 - a match, as long as there is a match, in the a and B is eligible, the function returns 1, otherwise it returns 0,

The above example, 12-1 - a and a is matching, 24-2 - c and c is match, as long as meet a matching returns 1,

1 - a, 1 b, 2 - a, 212-2 - c a, 23 - b, 124 - c return 1
1 - a, 1 b, 2 - a, 312-2 - c a, 23 - b, 224 - c return 1
1 - a, 1 b, 2 - a, 312-2 - c a, 23 - b, 124 - c returns 0

Java code implementation is as follows:
 
Public static int the compare (String A, String B) {
String [] arrA=A.s plit (", ");
String [] arrB=B.s plit (", ");

For (String child1: arrA) {
For (String child2: arrB) {
String [] split1=child1. Split (" - ");
String [] split2=child2. Split (" - ");
If (split2 [1]. The equals (split1 [1]) & amp; & Split2 [0]. StartsWith (split1 [0])) {
return 1;
}
}
}
return 0;
}


The bosses to write down the mysql function implementation, to make a query in the SQL statement because it is over, so can't use Java, I just write here, for example,

CodePudding user response:

Have bosses know how to write this function, please

CodePudding user response:

No one, that himself

CodePudding user response:

The original poster hello, mysql is used to query, you should at least provide your table structure and the results you want

CodePudding user response:

With regular, A and multiple rows of data in the database, you need A function that will be treated as A regular expression, match again B, return true | false.
A is A database or only one line, use process into regular, to execute A statement
  • Related