Aphanasiy Posted February 28, 2006 Share Posted February 28, 2006 Is it possible to union or join two UPDATE Queries to work at the same time? UPDATE ibf_dnames_change SET dname_previous='WizarD1' WHERE dname_previous='WizarD' JOIN UPDATE ibf_dnames_change SET dname_previous='zxcvbnm' WHERE dname_previous='coyl'/* How do I execute these two queries together please?Thank you, please do reply, need help. Link to comment Share on other sites More sharing options...
Pollux Posted February 28, 2006 Share Posted February 28, 2006 Generally you can execute two queries at once in SQL by separating them with a semi-colon. Although different databases can be slightly different. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 28, 2006 Share Posted February 28, 2006 you could also create the 2 queries as a stored procedure and then in your code execute the stored procedure. Link to comment Share on other sites More sharing options...
sbrownii Posted February 28, 2006 Share Posted February 28, 2006 If the WHERE condition were the same for both statements then you could combine them into one.http://dev.mysql.com/doc/refman/4.1/en/update.htmlJOIN is used for 2 different tables. You seem to be working with just one in those statements, so JOIN doesn't applyI don't understand why your statements would need to be in the same query. The aren't dependent on each other in any way. Just execute them separately. Link to comment Share on other sites More sharing options...
Aphanasiy Posted February 28, 2006 Author Share Posted February 28, 2006 you could also create the 2 queries as a stored procedure and then in your code execute the stored procedure.<{POST_SNAPBACK}> Could you please show me how this can be done in my case? Link to comment Share on other sites More sharing options...
aspnetguy Posted February 28, 2006 Share Posted February 28, 2006 Could you please show me how this can be done in my case?<{POST_SNAPBACK}> What database are you using? They all do stored procedures a bit different. Link to comment Share on other sites More sharing options...
Aphanasiy Posted February 28, 2006 Author Share Posted February 28, 2006 SQL Version MYSQL (4.0.25-standard) Link to comment Share on other sites More sharing options...
aspnetguy Posted March 1, 2006 Share Posted March 1, 2006 <{POST_SNAPBACK}> read thishttp://dev.mysql.com/doc/refman/5.0/en/sto...procedures.html Link to comment Share on other sites More sharing options...
syedhameed Posted March 2, 2006 Share Posted March 2, 2006 What database are you using? They all do stored procedures a bit different.<{POST_SNAPBACK}> UPDATE A SET A.FIELDNAME = "NEW VALUE" B.FIELDNAME = "NEW VALUE" FROM TABLE1 A, TABLE B WHERE A.ID = B.ID Link to comment Share on other sites More sharing options...
Guest Manju Posted March 2, 2006 Share Posted March 2, 2006 Is it possible to union or join two UPDATE Queries to work at the same time?UPDATE ibf_dnames_change SET dname_previous='WizarD1' WHERE dname_previous='WizarD' JOIN UPDATE ibf_dnames_change SET dname_previous='zxcvbnm' WHERE dname_previous='coyl'/* How do I execute these two queries together please?Thank you, please do reply, need help. <{POST_SNAPBACK}> Hi,It can not be done. Regards,Manju. Link to comment Share on other sites More sharing options...
syedhameed Posted March 2, 2006 Share Posted March 2, 2006 It is possibel....UPDATE ibf_dnames_change SET dname_previous = casewhen dname_previous = 'WizarD' then 'WizarD1'when dname_previous = 'coyl' then 'zxcvbnm'end Link to comment Share on other sites More sharing options...
aspnetguy Posted March 2, 2006 Share Posted March 2, 2006 UPDATE A SET A.FIELDNAME = "NEW VALUE" B.FIELDNAME = "NEW VALUE" FROM TABLE1 A, TABLE B WHERE A.ID = B.ID<{POST_SNAPBACK}> That will not work you can just execute the 2 seperate queries one after another....there is no need ot combine them but if you really want to just use a strored procedure. Link to comment Share on other sites More sharing options...
arief_anang Posted March 8, 2006 Share Posted March 8, 2006 In my opinion you can use two separate commands.UPDATE ibf_dnames_change SET dname_previous='WizarD1' WHERE dname_previous='WizarD';UPDATE ibf_dnames_change SET dname_previous='zxcvbnm' WHERE dname_previous='coyl';RegardsAnang Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now