MySQL - Select the last inserted row easiest way

后端 未结 9 1893
误落风尘
误落风尘 2020-11-30 09:56

I simply need to select the last entered row specified by condition, e.g:

SELECT ID from bugs WHERE user=Me

I need to return only the very

9条回答
  •  星月不相逢
    2020-11-30 10:10

    MySqlCommand insert_meal = new MySqlCommand("INSERT INTO meals_category(Id, Name, price, added_by, added_date) VALUES ('GTX-00145', 'Lunch', '23.55', 'User:Username', '2020-10-26')", conn);
    if (insert_meal .ExecuteNonQuery() == 1)
    {
        long Last_inserted_id = insert_meal.LastInsertedId;
        MessageBox.Show(msg, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Failed to save meal");
                }
    

提交回复
热议问题