Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use MySQl t increase Salary by percentage

    I have a table of employees that I want to give pay raises to. Part of the staff gets a 10% raise 5 employees and 12 employees gets a 5% pay raise.
    I need a single query that will work for either of the groups.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Feels like homework.

    No company I know would be giving exactly 5% and 10% (especially in these times) and in any case with only 17 employees I'm sure it would be faster and easier to just go in and edit the data. Oh, and a company wouldn't care if it was done with one query or two.

    And for homework, see rule 1.5 here:
    http://www.codingforums.com/rules.htm

    So convince us it's not homework or show us that you have made an effort to solve this.

    It's really not hard, honest. Here's a hint: Look at the IF( ) function.

    Oh, and in any case it would help a lot to show us the fields in the table that you are using.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Quote Originally Posted by lrcroft1 View Post
    I have a table of employees that I want to give pay raises to. Part of the staff gets a 10% raise 5 employees and 12 employees gets a 5% pay raise.
    I need a single query that will work for either of the groups.
    Definitely a homework assignment, and the solution is in your post.

    last_name | first_name | group

    Smith | Kevin | 1
    Brown | Jack | 2
    Jackson | Bill | 2
    Thompson | Jack | 2


    ----------------
    Leonard Whistler


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •