MySQL WHERE clause construction issue -


I use this to filter records by LocState: (States have been passed as pipes, As the values ​​shown below, but there will be a parameter) INSTR (CONCAT ('|', 'TX | OH', '|'), e.Loccetate) & gt; 0

But ... how can I work for it?

  INSTR (CONCAT ('' ',' AO | WH15 ',' | '), e. Program code) & gt; 0   

This also causes a match for programcode == 'WH1'.

  POSITION (e.ProgramCode IN CONCAT ('|', 'AO | WH15', '|')) & gt; 0   

Either does not work.

We tell you such data records are:

  ID programcode 1 WH1 2 WH15   

and you want to filter the records that match WH1 . If you are using this query:

  SELECT * to the table WHERE ProgramCode INSTR (CONCAT ('|', 'AO | WH15', '|'), E. Progression) Gt; 0   

You are essentially saying:

Choose the record code where the program code is in the following string: '| A0 | WH15 | '

And since 'WH1' these 'WH15' you get a wrong Get Positive

You would be better off using the WHERE IN build, such as:

  SELECT * to the table WHERE ProgramCode IN ('A0', 'WH15 ');   

This means:

Select the record where the program code (in its entirety) is in the following set of string: 'A0' , 'WH15'

If your filter criteria has been passed as a pipe-delimited string, you should first parse it So that you can IN logic.

You may be interested in using it even after supporting MySQL.

Comments