我有一个数据库表,我需要验证用户是否输入了相同或部分相同的信息。
这就是我的想法
数据库布局
rec_id (pk), user_id,
name, phone, address_1, address_2, zip,
company, co_phone, co_address_1, co_address_2, co_zip,
billing, bi_phone, bi_address_1, bi_address_2, bi_zip
查询
SELECT rec_id
FROM tbl_name
WHERE user_id = '123456789'
OR '1112223333' IN (phone, co_phone, bi_phone)
OR 'John Doe' IN (name, business, billing)
OR '12345' IN (zip, co_zip, bi_zip)
OR '123 main street' IN (address_1, co_address_1, bi_address_1)
OR 'po box 123' IN (address_2, co_address_2, bi_address_2)
如果任何数据匹配(是的,这将是误报),我需要旧的 rec_id。
想知道是否有更好的方法来做到这一点?
谢谢