EasyToLearn-PHP

This blog will help you in web designing & development like HTML,CSS, HTML5,JAVASCRIPT,PHP,MySQL

Tuesday, 1 August 2017


Given a table SALARIES, such as the one below, that has m and f values. Swap all f and m values with a single update query and no intermediate temp table.


Id Name Sex Salary 1 A m 2500 2 B f 1500 3 C m 5500 4 D f 500


UPDATE SALARIES SET sex = CASE sex WHEN 'm' THEN 'f' ELSE 'm' END



Posted by raannu at 00:50 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Blog Archive

  • ▼  2017 (2)
    • ▼  August (1)
      • Given a table SALARIES, such as the one below, t...
    • ►  July (1)
  • ►  2016 (12)
    • ►  August (11)
    • ►  July (1)
  • ►  2013 (8)
    • ►  August (1)
    • ►  June (3)
    • ►  May (4)
  • ►  2012 (1)
    • ►  January (1)
  • ►  2011 (3)
    • ►  July (3)

Pages

  • Home
  • Contact Us

Blog Archive

  • ▼  2017 (2)
    • ▼  August (1)
      • Given a table SALARIES, such as the one below, t...
    • ►  July (1)
  • ►  2016 (12)
    • ►  August (11)
    • ►  July (1)
  • ►  2013 (8)
    • ►  August (1)
    • ►  June (3)
    • ►  May (4)
  • ►  2012 (1)
    • ►  January (1)
  • ►  2011 (3)
    • ►  July (3)

About Me

raannu
View my complete profile
Simple theme. Powered by Blogger.