b1011 Posted May 21, 2007 Share Posted May 21, 2007 i am using php and mysql. i need this in Mysql: if value exists in colum 'gangname' then execute code. any ideas? do you know what i mean? im adding a new row, and i dont want the gangname the same as any other ones, so i need to check if the name exists so i DONT execute code. Quote Link to comment https://forums.phpfreaks.com/topic/52380-if-value-exists/ Share on other sites More sharing options...
pikemsu28 Posted May 21, 2007 Share Posted May 21, 2007 use REPLACE instead of INSERT in your query REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a Primary Key or a UNIQUE index, the old row is deleted beore the new row is inserted. be carefull when using REPLACE, it will delete the existing record and add a new row at the end which will leave spaces in any auto_inc columns. http://dev.mysql.com/doc/refman/5.0/en/replace.html Quote Link to comment https://forums.phpfreaks.com/topic/52380-if-value-exists/#findComment-258474 Share on other sites More sharing options...
binindex Posted May 22, 2007 Share Posted May 22, 2007 do you mean see if the gang name exists if it does then do this part of code in say php or do this. Using it like an if? Quote Link to comment https://forums.phpfreaks.com/topic/52380-if-value-exists/#findComment-258729 Share on other sites More sharing options...
pikemsu28 Posted May 22, 2007 Share Posted May 22, 2007 can you post any code? Quote Link to comment https://forums.phpfreaks.com/topic/52380-if-value-exists/#findComment-258981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.