The given SQL statement is written in VB.NET and it retrieves all the rows from the "users" table where the "id" column matches the provided ":id" parameter value, and the "email_address_id" column matches any of the IDs obtained from the subquery.

Here is an example of how you can execute this query using VB.NET:

Dim query As String = "SELECT * FROM users WHERE id = @id AND email_address_id IN (SELECT id FROM email_addresses WHERE user_id = @id)"

Using connection As New SqlConnection("YourConnectionString")
    Using command As New SqlCommand(query, connection)
        command.Parameters.AddWithValue("@id", yourIdValue)

        connection.Open()

        Using reader As SqlDataReader = command.ExecuteReader()
            While reader.Read()
                ' Access the retrieved data using reader.GetString(), reader.GetInt32(), etc.
            End While
        End Using
    End Using
End Using

Make sure to replace "YourConnectionString" with the actual connection string to your database, and "yourIdValue" with the appropriate value for the ":id" parameter.

vbnetSELECT FROM users WHERE id = id AND email_address_id IN SELECT id FROM email_addresses WHERE user_id = id

原文地址: https://www.cveoy.top/t/topic/iCR6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录