Q:

Find a user_id from string where id is one digit or 2 digit using SQL Server query

Here is my C# code 
private DataTable bindTrainingAttendeedGridView(string condition)
{
    DataTable dtGrid = new DataTable();
    con. ConnectionString = constr;

    string query = "select training_id,CONVERT(varchar(10),training_date,101) AS Training_date,topic,trainee from tbl_training_attendee where 1=1 " + condition;

    SqlCommand cmd = new SqlCommand(query, con);
    SqlDataAdapter sqladapter = new SqlDataAdapter(cmd);
    sqladapter. Fill(dtGrid);

    if (dtGrid. Rows. Count <= 0)
    {
        Label1.Text = "No Matching Training taken Entries Found, Thank You."; 
    }
    else
    {
        Label1.Text = "";
    }

    //con. Open();
    return dtGrid;
}

protected void TrainingAttendenceGridViewBind(string condition)
{
    try
    {
        TrainingAttendeedGridView. DataSource = bindTrainingAttendeedGridView(condition);
        TrainingAttendeedGridView. DataBind();
    }
    catch (Exception er)
    {
        throw er;
    }
}

protected void training_attendence_condition()
{
    string condition = "";

    if (UserDropDownList. SelectedIndex > 0)
    {
        condition += "AND PATINDEX('%61%',trainee)!=0 or(PATINDEX('%,61,%',trainee)!=0 and PATINDEX('%,61%',trainee)!=0 and PATINDEX('%61,%',trainee)!=0 ) 
    }

    TrainingAttendenceGridViewBind(condition);
}

In training_attendence_condition, I can write a query for getting user_id for that row but it can show only two digit number records and when take one digit number then it can return that number with second digit.  So please help to get both one or two digits

A:

Try this SQL query no need of training_attendence_condition you can directly write query as given :
select training_id,CONVERT(varchar(10),training_date,101) AS Training_date,topic,trainee from tbl_training_attendee where CONCAT( ',',trainee,',') like CONCAT( '%,','61',',%' )

