Prevent duplicate record - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Prevent duplicate record (/showthread.php?tid=76690) |
Prevent duplicate record - omid_student - 06-10-2020 Hi I have a like table that have user_id and comment_id field I need user only can like once each comment and i dont want to check it with SELECT Maybe adjust table column that occur error when insert record? Like primary error I attach my table shot I want only insert record example user_id,comment_id 2,4 for next insert,show error for insert Maybe? RE: Prevent duplicate record - InsiteFX - 06-10-2020 There is no way to check it without using a select. Code: SELECT EXISTS(SELECT * FROM yourTableName WHERE yourCondition); I would make sure that both columns are index. RE: Prevent duplicate record - omid_student - 06-10-2020 (06-10-2020, 03:07 AM)InsiteFX Wrote: There is no way to check it without using a select.Thanks but I remember we could implement this feature with add key on fields and prevent duplicate records But i dont know how do it RE: Prevent duplicate record - InsiteFX - 06-10-2020 Not sure but this might be what your looking for. MySQL - Handling Duplicates RE: Prevent duplicate record - omid_student - 06-10-2020 (06-10-2020, 07:59 AM)InsiteFX Wrote: Not sure but this might be what your looking for. Thank you (06-10-2020, 07:59 AM)InsiteFX Wrote: Not sure but this might be what your looking for.It's working good very thanks |