Is it possible to bulk update? I did a build insert, now I would like to update each of the user IDs to increase the count.
Here's a sample of my build insert
void updateMediaForSubscribers(long userId, long mediaId, Media_Base.Catagory cat, DateTime currentDate)
{
command.CommandText =
"INSERT INTO user_media_subscription (recipientId, mediaId, catagory) " +
"SELECT watcher, @mediaId, @category " +
"FROM user_watch WHERE watched=@watched;";
command.Parameters.Add("@mediaId", DbType.Int64).Value = mediaId;
command.Parameters.Add("@category", DbType.Int64).Value = cat;
command.Parameters.Add("@watched", DbType.Int64).Value = userId;
command.ExecuteNonQuery();
//now I want to increase but this syntax is wrong
//currently near "LEFT": syntax error
//this is made up and shouldn't work.
command.CommandText =
"UPDATE user_data SET mediaMsgCount=mediaMsgCount+1 " +
"LEFT JOIN user_watch AS w ON w.watcher=user_data.userId " +
"WHERE w.watched=@watched;";
command.Parameters.Add("@watched", DbType.Int64).Value = userId;
command.ExecuteNonQuery();
}