Kiếm tra 1 chuỗi tồn tại trong column của table trong Mysql
Em chào mọi người.
Trong MySQL của em có:
Database: People
Table: NameGiờ em muốn kiểm tra string "Nguyễn Văn A" đã tồn tại trong table "Name" chưa thì làm thế nào ạ ?
Rất mong mọi người hỗ trợ em đoạn code.
Em xin cảm ơn!
Cảm ơn mọi người. Em tìm được rồi ạ.
Dim issue As String
Dim rst As Object
Dim result As Integer
Dim sql As String
issue = "hello"
Dim con As ADODB.Connection
Set con = New ADODB.Connection
Set con = CreateObject("ADODB.Connection")
con.Open "Driver={MySQL ODBC 8.0 Unicode Driver};Server=localhost;Database=People;Uid=user1;Pwd=Abc123;"
''Sql = "select count(*) as row_count from employee where employeeid = '" & UserName & "' and password = '" & Password & "';"
sql = "select count(*) as row_count from main where issue = '" & issue & "';"
Set rst = con.Execute(sql)
result = rst!row_count
If result = 1 Then
MsgBox "OK"
Else
MsgBox "No"
End If
www.giaiphapexcel.com/diendan/threads/ki%E1%BA%BFm-tra-1-chu%E1%BB%97i-t%E1%BB%93n-t%E1%BA%A1i-trong-column-c%E1%BB%A7a-table-trong-mysql.151345/
Kỹ năng giải quyết vấn đề hiệu quả
Mô tả Nội dung Đánh giá Tài nguyên KỸ NĂNG GIẢI QUYẾT VẤN ĐỀ HIỆU QUẢHiểu đúng vấn đề là một nửa của giải...
Xem khóa học