Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2010, 09:16 PM   PM User | #1
lrcroft1
New to the CF scene

 
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
lrcroft1 is an unknown quantity at this point
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.
lrcroft1 is offline   Reply With Quote
Old 01-11-2010, 09:56 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,200
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
Old Pedant is offline   Reply With Quote
Old 01-11-2010, 10:24 PM   PM User | #3
Len Whistler
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
Len Whistler is on a distinguished road
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
Len Whistler is offline   Reply With Quote
Reply

Bookmarks

Tags
increase, percentage, salary

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:55 PM.


Advertisement
Log in to turn off these ads.