I need to create a set of views in which a database user with select permissions will query data, but I want to create a generic view, so if other users want to query the same data, I wouldn't need to create more views based on theirs "user_id". An example would be:
CREATE OR REPLACE VIEW user_data AS SELECT * FROM users JOIN something WHERE user_id = ?
Is there any way to set that if the database user querying data is "db_user1", then the view with the above select would query using 1
as the user_id
? And if the database user is db_user2
than the where user_id
would be set to 2?