sql - MySQL: Using REPLACE as part of an IN statement -


I'm trying to replace the comma instead of the empty space.

If I try the place of selection ('1 2 3 4 5 6 7 86 9', '', ','); So I get exactly what I want in the string.

However, if I look at it as part of an end statement, then I only return the first match (i.e., 1)

This is my complete query:

> Where or select aa.category_id, aa.yyyymm, aa.cat_balance_ytd gl_view_cat_balances aa.gl_id = '/ job // 9 and aa.fin_years_ago = 0 ** and (in aa.category_id REPLACE (option_id where detail_2 from gl_options as (select = 'GLREPFUNCJOB01'), ',', ')) ** Aakyyyymm and = (max (bb.yyyymm) bb where bb.gl_unique_id as gl_rep_cat_bals = Select aa.gl_unique_id and bb.category_id = Aa.category_id and bb.yyyymm & lt; = 200910);

In the record GLRPFNCJob 01 includes '1 2 3 4 5 6 7 86 9' in field description 2

If someone has some useful signals that I How can I get the string in coma and use it in IN IN. I would like to hear about them

You can not use a comma for use in a IN section To re-create a delimited list, use it again, to use it, you must use (effectively dynamic SQL) - first create a separate comma separated list, and insert it into the SQL query created in the string before executing it do.

  a.category_id, a.yyyymm, on a.cat_balance_ytd select Join a GL_VIEW_CAT_BALANCES GL_OPTIONS o INSTR (o.detail2, a.category_id) and o.option_id = 'GLREPFUNCJOB01' JOIN (select b.category_id, b.gl_unique_id, Max (b.yyyymm) GL_REPCAT_BALSs the 'YYYYMM' B where b.yyyymm & LT; b.category_id by = 200 910 Group, b.gl_unique_id) x.category_id = X a.category_id And x.gl_unique_id = a.unique_id and x.yyyymm = A.yyyymm WHERE a.gl_id = '/ JOB // 9' and a.fin_years_ago = 0  

using here select a Anchestr, possible non-dynamic SQL options:

  select a.category_id, a.yyy YMM, a.cat_balance_ytd from GL_VIEW_CAT_BALANCES a JOIN (REPLACE (o.detail_2, ' ',', ')' GLREPFUNC JOB01 'GL_OPTIONS O ou'option_id =' detail2_csv ') at y FIND_IN_SET (a.category, y.detail2_csv) & gt; Select 0 JOIN (b.category_id, b.gl_unique_id, Max (b.yyyymm) GL_REPCAT_BALSs the 'YYYYMM' B where b.yyyymm & lt; = 200,910 b.category_id group, b.gl_unique_id) x.category_id X = A Category_id and x.gl_unique_id = a.unique_id and x.yyyymm = a.yyyymm WHERE a.gl_id = '/ JOB // 9' and a.fin_years_ago = 0  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -