I’ve got a load of tables within which the records can have a category (identified by the “category_id” field). There’s obviously a “category” table that defines all of these categories, and this is shared by all tables.
Now, if the users wishes to remove a category, I need to check each of the tables to see if it’s ID is used by any of the records. Obviously I could do:
SELECT * FROM event WHERE category_id=’x’;
SELECT
.
.
.
SELECT * FROM quicklinks WHERE category_id=’x’;
SELECT
Ad nauseaum, but is there a way of checking if this id is contained within [I]any
It would be escpecially useful as some of the tables may not exist, each client has their own database with selected tables contained therein.
Any ideas?