I do have a lot of tables. In every table there is a user_id as foreign_key pointing to user.id (user table, primary key). This is for recording which user inserted/changed data.
Now I want to know in which tables a user inserted data.
Is there a simple trick without joining all tables?
- I dont expect the data (can query that later)
- I dont need to know to which tables the foreign_key points to the user table (I already know)
- I want to know where user data is related
I could join all Tables, but this would be a huge performance issue. There are a lot tables and some are big, too.
I'm looking for something like:
SELECT tablename
FROM information_schema.foo
WHERE foreign_key = "key_name" AND foreign_key_value = 2;