How to check if a given data exists in multiple tables (all of which has the same column)?

后端 未结 6 1219
眼角桃花
眼角桃花 2020-12-06 05:48

I have 3 tables, each consisting of a column called username. On the registration part, I need to check that the requested username is new and unique.

I need that si

6条回答
  •  广开言路
    2020-12-06 06:31

    No. Two processes could run your test at the same time and both would report no user and then both could insert the same user.

    It sounds like you need a single table to hold ALL the users with a unique index to prevent duplicates. This master table could link to 'sub-tables' using a user ID, not user name.

提交回复
热议问题