<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: sql select statement with field having multiple values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558891#M1937178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gaurav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you have explained, If values(a1,a2,..a5) are entered by user on selection screen in that case you can go with select options. For select-options you can hide intervals and button using some extensions for select-options.&lt;/P&gt;&lt;P&gt;If these values are constants, in that case you can create ranges and populate it with values.&lt;/P&gt;&lt;P&gt;Once you have select-option/ranges with you, you can hit select statement where you need to keep all fields with "AND" conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another way you can solve this problem is by dynamic query. In that case you create clause after "WHERE" in select statement in one string(Say str_whr) and use it in select statement(SELECT * FROM xyz WHERE (str_whr). here str_whr = 'field1 = a1 or field3 = a3 or field4 = a4')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Hardik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Mar 2016 11:37:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2016-03-30T11:37:53Z</dc:date>
    <item>
      <title>sql select statement with field having multiple values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558889#M1937176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have few check-boxes on my selection screen.Each check-box corresponds to a value which a field of a table can take.I have to then fire a select query where a particular field of a table can have all values whose corresponding check-box is selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose i have 5 check-box corresponding to values a1,a2 till a5.&lt;/P&gt;&lt;P&gt;Now if check-box 1 ,3 and 4 is checked then the filed of table can have values a1 or a3 or a4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;select * from table where field = a1 or field = a2 or field = a3.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;One way to do this is creating 5 variables and then doing something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if checkbox1 checked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then var1 = a1&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1 = '0'&amp;nbsp;&amp;nbsp;&amp;nbsp; //something which would never occur in the field of the table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on for all checkboxes.&lt;/P&gt;&lt;P&gt;and then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt;select * from table where field = var1 or field = var2 or field = var3 or field = var4 or field = var5.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Is there a better way to do this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 06:03:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558889#M1937176</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-03-30T06:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: sql select statement with field having multiple values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558890#M1937177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Define a TYPE RANGE data and fill it with the checked values&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;SPAN style="color: #0000ff;"&gt;DATA&lt;/SPAN&gt;: my_range &lt;SPAN style="color: #0000ff;"&gt;TYPE&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;RANGE&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;OF&lt;/SPAN&gt; my_element&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;SPAN style="color: #0000ff;"&gt;REFRESH&lt;/SPAN&gt; my_range&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;SPAN style="color: #0000ff;"&gt;IF&lt;/SPAN&gt; checkbox1 &lt;SPAN style="color: #0000ff;"&gt;IS&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;NOT&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;INITIAL&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;APPEND&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;INITIAL&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;LINE&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;TO&lt;/SPAN&gt; my_range &lt;SPAN style="color: #0000ff;"&gt;ASSIGNING&lt;/SPAN&gt; &lt;SPAN style="color: #800097;"&gt;&amp;lt;&lt;/SPAN&gt;value&lt;SPAN style="color: #800097;"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&amp;nbsp; &lt;SPAN style="color: #800097;"&gt;&amp;lt;&lt;/SPAN&gt;value&lt;SPAN style="color: #800097;"&gt;&amp;gt;&lt;/SPAN&gt;-sign&lt;SPAN style="color: #800080;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: #4da616;"&gt;'I'&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&amp;nbsp; &lt;SPAN style="color: #800097;"&gt;&amp;lt;&lt;/SPAN&gt;value&lt;SPAN style="color: #800097;"&gt;&amp;gt;&lt;/SPAN&gt;-option&lt;SPAN style="color: #800080;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: #4da616;"&gt;'EQ'&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&amp;nbsp; &lt;SPAN style="color: #800097;"&gt;&amp;lt;&lt;/SPAN&gt;value&lt;SPAN style="color: #800097;"&gt;&amp;gt;&lt;/SPAN&gt;-low&lt;SPAN style="color: #800080;"&gt; = &lt;/SPAN&gt;field1&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;SPAN style="color: #0000ff;"&gt;ENDIF&lt;/SPAN&gt;&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;/P&gt;
&lt;P style="font-family: courier; color: black;"&gt;&lt;SPAN style="color: #0000ff;"&gt;SELECT&lt;/SPAN&gt; * &lt;SPAN style="color: #0000ff;"&gt;FROM&lt;/SPAN&gt; my_table &lt;SPAN style="color: #0000ff;"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;field&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;IN&lt;/SPAN&gt; my_range&lt;SPAN style="color: #800080;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could also use some dynamic assignment to checkbox and value with field symbols (or the obsolete DO VARYING for the nostalgics only.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raymond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 06:19:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558890#M1937177</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2016-03-30T06:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: sql select statement with field having multiple values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558891#M1937178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gaurav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you have explained, If values(a1,a2,..a5) are entered by user on selection screen in that case you can go with select options. For select-options you can hide intervals and button using some extensions for select-options.&lt;/P&gt;&lt;P&gt;If these values are constants, in that case you can create ranges and populate it with values.&lt;/P&gt;&lt;P&gt;Once you have select-option/ranges with you, you can hit select statement where you need to keep all fields with "AND" conditions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another way you can solve this problem is by dynamic query. In that case you create clause after "WHERE" in select statement in one string(Say str_whr) and use it in select statement(SELECT * FROM xyz WHERE (str_whr). here str_whr = 'field1 = a1 or field3 = a3 or field4 = a4')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Hardik&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2016 11:37:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/sql-select-statement-with-field-having-multiple-values/m-p/11558891#M1937178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-03-30T11:37:53Z</dc:date>
    </item>
  </channel>
</rss>

