I have a database table from which, when I select data with username and password, it works but when I insert some data in that table with same username and password it show
In your query you might be using table name with database name "INSERT INTO DB_NAME.table_name ..." where you database user do not have insert permissions for DB_NAME. So this error is coming because query is pointing to the table of another database.
You need to remove the database name or use correct database name either.