Home > Back-end >  Do not make the Delphi development eight years now, encounter problems please expert help
Do not make the Delphi development eight years now, encounter problems please expert help

Time:09-30

Data table name SJB field wl (code) gg (specifications)

Enter a material number to find out the corresponding specification
The format of the specification from 124 * 12 * 278 or 124 x 12
Requirement is to search out all the specification of the same data, the problem is
Phi 124 * 12 * 278 the same specifications such as 124 x 278 x 12 phi phi 12 x 278 x 124
Phi 12 x 124 x 278 12 phi phi 278 * 124 * 278 * 12 * 124

Phi 12 same specifications such as 12 x 124 x 124



CodePudding user response:

Before and after the first x number, all to pose in size order
Such as phi 124 12 x 124 x 12 will be changed to phi, and phi 12 x 124 you don't need to change, because 124 is more than 12 (can be numerical size 9 & lt; 10, also can be the string size 9 & gt; 10)

However, I am more interested in: why eight years and Delphi live?

CodePudding user response:

Select * from SJB where gg like '% 12 x124 %' or gg like '% 124 x12 % or gg like 12 x278 % %' or 'gg like % 124 x278 %' or...

CodePudding user response:

He Delphi it doesn't matter, direct use SQL to solve it; Using a temporary table may be convenient, if using the function is expected to slow.

CodePudding user response:

refer to the original poster cooli_li response:
data table name SJB field wl (code) gg (specifications)

Enter a material number to find out the corresponding specification
The format of the specification from 124 * 12 * 278 or 124 x 12
Requirement is to search out all the specification of the same data, the problem is
Phi 124 * 12 * 278 the same specifications such as 124 x 278 x 12 phi phi 12 x 278 x 124
Phi 12 x 124 x 278 12 phi phi 278 * 124 * 278 * 12 * 124

Phi 124 x 12 same specifications such as 12 x 124


My idea is to put the specifications into 124,12,278, then combination, finally written in SQL problem is now forgot how to put the phi 124 * 12 * 278 into three Numbers, the code of points can add enough,,

CodePudding user response:

The most three numerical? The use of a temporary increase in 3 numeric fields, write SQL also may be able to do

However, better application traverse the split line by line, sorting, update,,,,

CodePudding user response:

My idea is to put the specifications into 124,12,278, then combination, finally written in SQL problem is now forgot how to put the phi 124 * 12 * 278 into three Numbers, code of points is not enough to add,,


Should be split into three Numbers, and can decompose step by step, the best written to call a stored procedure,


DECLARE @ STR varchar (50), @ str1 varchar (50), @ str2 varchar (50), @ str3 varchar (50), @ xx int

The SET @ STR='phi 124 * 12 * 278'
SELECT @ STR=LTRIM (REPLACE (@ STR, 'phi', '))

SELECT @ xx=charindex (' x '@ STR)
SELECT @ str1=the Substring (@ STR, 0, @ xx)
SELECT @ STR=the Substring (@ STR, @ xx + 1, Len (@ STR) - @ xx)

SELECT @ xx=charindex (' x '@ STR)
SELECT @ str2=the Substring (@ STR, 0, @ xx)
SELECT @ str3=the Substring (@ STR, @ xx + 1, Len (@ STR) - @ xx)

- print @ str1
- print @ str2
- print @ str3


CodePudding user response:


This is a design problem.

CodePudding user response:

Should be unified format, and index, and can improve the efficiency of the query,

CodePudding user response:

refer to the original poster cooli_li response:
data table name SJB field wl (code) gg (specifications)

Enter a material number to find out the corresponding specification
The format of the specification from 124 * 12 * 278 or 124 x 12
Requirement is to search out all the specification of the same data, the problem is
Phi 124 * 12 * 278 the same specifications such as 124 x 278 x 12 phi phi 12 x 278 x 124
Phi 12 x 124 x 278 12 phi phi 278 * 124 * 278 * 12 * 124

Phi 124 x 12 same specifications such as 12 x 124

According to your description:
Need to do split combination query conditions, such as 124 * 12 * 278, and can get the following factors (no considering the diversity of the connector specification parameters, the only recognised x)
124, 12, 278 (A, B, C)
Can get 6 kinds of combination of ABC, ACB, BAC, BCA, CAB, CBA
For the six kinds of combination query conditions can.
Split rules can according to your actual usage scenarios.

CodePudding user response:

Is the most simple and effective method in before writing data into the database, to do sorting specification parameters, it will be easier,

CodePudding user response:

Advice on specification character sorting,

CodePudding user response:

CodePudding user response:

Requirements of the building Lord is input phi 124 * 12 * 278 specification criteria query, can turn to the related specifications are found out

Can be split before query
Part of the code:
STR:='phi 124 * 12 * 278;//STR=to query the specifications of the
If the Copy (STR, 1, 1)='phi' then STR:=Copy (STR, 2, Length (STR) - 1);//remove the previous phi symbol

IPoint:=point (' x ', STR);//to take the position of the first x
If iPoint> 0 then s1:=Copy (STR, 1, iPoint - 1);//the first specification string

STR:=Copy (STR, iPoint + 1, Length (STR) - iPoint);
IPoint:=point (' x ', STR);//to take the position of the second x
If iPoint> 0 then
The begin
S2:=Copy (STR, 1, iPoint - 1);//the second specification string
S3:=Copy (STR, iPoint + 1, Length (STR) - iPoint);//the third specification string
End
The else
The begin//there are only two of the specifications of the string
S2:=STR;
S3:=';
end;

Query:
Will divide the two cases, one kind is the s3 is not empty, one kind is the s3 is empty
If the s3 & lt;> "' then//a total of nine
SQL. Text:='select * from SJB where (gg like' % '+ +' s1 '+ s2 + x x' + s3 + '%') or (gg like '%' + + 's1' + s3 + x x '+ s2 +' % ') or... '
End
The else//2 combinations
SQL. Text:='select * from SJB where (gg=' phi '+ s1 + x + s2' + ' ' ') or (gg='phi' + s2 + 'x' + + 's1') '.

CodePudding user response:

In front of the query is wrong: in the like, because some have phi symbols, some not
Will divide the two cases, one kind is the s3 is not empty, one kind is the s3 is empty
If the s3 & lt;> "' then//a total of nine
SQL. Text:='select * from SJB where (gg like' % '+ +' s1 '+ s2 + x x' + s3 + '%') or (gg like '%' + + 's1' + s3 + x x '+ s2 +' % ') or... '
End
The else//2 combinations
SQL. Text:='select * from SJB where (gg like' % ', '+ s1 + x' + s2 + '%') or (gg like '%', '+ s2 +' x '+ s1 +' % ') '.

CodePudding user response:

Characters must be sorted to specifications

CodePudding user response:

Break up is not possible, because the specification number available, if there are five parameters, combination is a lot

CodePudding user response:

For eight years, this cannot solve?

CodePudding user response:

I am in favor of the 13 floor,

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related