title: How to Append dynamic value in database query?
body: <p><strong>Java Code</strong>:</p>
  
  <pre><code>String ds=null;
  String client=null;
  List&lt;Date&gt; dates = new ArrayList&lt;Date&gt;();
  String str_date ="2015-04-05";
                      String end_date ="2015-04-10";
                              int s=dates.size();
                              System.out.println("Date size value"+s);
                              for(int i=1;i&lt;dates.size();i++){
                                  Date lDate =(Date)dates.get(i);
  
                                   ds = formatter.format(lDate);    
                                  System.out.println(" Date is ..." + ds);
  
                              }
                              for(int i=0;i&lt;s;i++)
                              {
                              query0 = "SELECT  TransDate FROM abc.`"
                                      + str_date + "` WHERE `Id`='" + Id + "'";
                              query1 = "SELECT  TransDate FROM mis.`"
                                      + ds + "` WHERE `Id`='" + Id + "'";
  
  
                  finalQuery = query0 + " " + " union all " + " " + query1;
                                                      }
          System.out.println("finalquery  =====   " + finalQuery);
        }
  </code></pre>
  
  <p><strong>output</strong></p>
  
  <pre><code>I am getting output like this 
   Date size value6
   Date is ...2015-04-06
   Date is ...2015-04-07
   Date is ...2015-04-08
   Date is ...2015-04-09
   Date is ...2015-04-10
  finalquery  =====   SELECT  TransDate  FROM mis.`2015-04-05` WHERE `Id`='null'  union all  SELECT  TransDate  FROM mis.`2015-04-10` WHERE `Id`='null'    
      But I need output like this 
      SELECT  TransDate  FROM mis.`2015-04-05` WHERE `Id`='null'  union all           SELECT  TransDate  FROM mis.`2015-04-06` WHERE `Id`='null' union all
      SELECT  TransDate  FROM mis.`2015-04-07` WHERE `Id`='null' union all
      SELECT  TransDate  FROM mis.`2015-04-08` WHERE `Id`='null'union all
      SELECT  TransDate  FROM mis.`2015-04-09` WHERE `Id`='null' union all
      SELECT  TransDate  FROM mis.`2015-04-10` WHERE `Id`='null'
  </code></pre>
  
  <p>The above code getting fromdate ,todate between dates.Those dates will append in String of query . please tell how to get this output.... Thanks in advance</p>