只做备注

Sub general_sql_macro()
   Sql = ""
   column_name = "user_count"
   Sql = "insert into `mytable` (date," + column_name + ") values "
   
    For Row = 1 To 1000
        date_str = CStr(Sheets("Sheet1").Cells(Row, 1).Value)
        If date_str = "" Then
           Exit For
        End If
        If Row <> 1 Then
          Sql = Sql + ","
        End If
        Value = Sheets("Sheet1").Cells(Row, 2).Value
      
         insert_value = "('" + date_str + "'," + CStr(Value) + ")"
         Sql = Sql + insert_value
        
    Next Row
    Sql = Sql + " on DUPLICATE KEY UPDATE " + column_name + "=values(" + column_name + ")"
    Sheets("Sheet1").Cells(5, 5).Value = Sql
    
End Sub

 

相关文章:

  • 2021-09-29
  • 2022-12-23
  • 2021-11-21
  • 2022-01-25
  • 2021-09-02
  • 2021-10-06
  • 2021-12-30
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案