title: Pupulate table with data in mysql
body: <p>I have two databases</p>
  
  <ol>
  <li><p>db1</p></li>
  <li><p>db2</p></li>
  </ol>
  
  <p>db1 has table <strong>controller</strong>  below the description of controller table.</p>
  
  <pre><code>+-----------------------+--------------+------+-----+---------+-------+
  | Field                 | Type         | Null | Key | Default | Extra |
  +-----------------------+--------------+------+-----+---------+-------+
  | id                    | int(11)      | NO   | PRI | NULL    |       |
  | interface_name        | varchar(255) | YES  |     | NULL    |       |
  | store_number          | int(11)      | YES  |     | NULL    |       |
  | file_seq_no           | int(11)      | YES  |     | NULL    |       |
  | packet_seq_no         | int(11)      | YES  |     | NULL    |       |
  | last_trans_start_date | date         | YES  |     | NULL    |       |
  | last_trans_end_date   | date         | YES  |     | NULL    |       |
  | last_extract_datetime | datetime     | YES  |     | NULL    |       |
  | is_enabled            | char(1)      | YES  |     | NULL    |       |
  +-----------------------+--------------+------+-----+---------+-------+
  </code></pre>
  
  <p>and same table description and additional column(date_opened) with different name available in database <strong>db2</strong> with name store table.</p>
  
  <p>My job is to write a query based on below logic.</p>
  
  <p>Point 1 : Fetch all store_number, date_opened from db2.store.</p>
  
  <p>Point 2 : Fetch all store_number from db1.controller table into list.</p>
  
  <p>Point 3 : Filter new store_number fetched from db2.store not present in db1.controller.</p>
  
  <p><strong>For each of these new store_number</strong></p>
  
  <p>insert default initial values for new stores, file_seq_number and packet_seq_number will be set as zero.</p>
  
  <p>last_transaction_start_date , last_transaction_end_date , last_extract_timestampwill be store creation date ie db2.store.date_opened</p>
  
  <p>enabled will be set as 1</p>
  
  <p>Main query would be </p>
  
  <pre><code>Insert into db1.controller table values( store_number, 0, 0,$date_opened,$date_opened,
  $date_opened,1);
  </code></pre>
  
  <p>Can any one please help me to complete this sql query.</p>
  
  <p>Thanks in advance</p>