C# 使用C从SQL表中提取特定数据

C# 使用C从SQL表中提取特定数据,c#,sql-server,C#,Sql Server,我正在从事一个项目,需要从SQL中的表中提取特定数据。我对SQL相当陌生,因此给出的所有示例对我的项目过程都没有帮助 我试图只提取其中有四个特定值的行,但我不确定在C中如何做。我必须运行一个长查询,还是可以运行多个查询,并且C将具有提取项目所需的内容所需的内容 这就是我目前所处的位置 public static List<string> GetSmoothieFlavors() { List<string> flavors = new List<string

我正在从事一个项目,需要从SQL中的表中提取特定数据。我对SQL相当陌生,因此给出的所有示例对我的项目过程都没有帮助

我试图只提取其中有四个特定值的行,但我不确定在C中如何做。我必须运行一个长查询,还是可以运行多个查询,并且C将具有提取项目所需的内容所需的内容

这就是我目前所处的位置

public static List<string> GetSmoothieFlavors()
{
    List<string> flavors = new List<string>();
    SqlCommand getFlavorsQuery = new SqlCommand("select * from smoothieFlavors", conn);
    try
    {
        conn.Open();
        SqlDataReader reader = getFlavorsQuery.ExecuteReader();
        while (reader.Read())
        {
            flavors.Add(reader.GetString(0));
        }
        conn.Close();
        return flavors;
    }
    catch (Exception ex)
    {
        throw new POSException(ex);
    }
}

一种非常简单的方法是以这种方式在查询中使用where子句

SqlCommand getFlavorsQuery = new SqlCommand("select * from smoothieFlavors where column1 = value1 and column2 = value2", conn)

为什么不修改SQL以只返回四个特定值:从smoothieFlavors中选择*,其中SomeVal位于“blueberry”、“草莓”、“cheesecurds”、“bacon”中