...

View Full Version : relational databases loop?



jayemvee
02-02-2007, 12:06 AM
Hey im having a little trouble...
I am looping through a few tables to calculate interest rates heres the basics for the loop.

First is a foreach for the loan types and then nested inside that there is a while loop to come up with all the different banks information containing that loan type.

The kicker is now i need to make adjustments based on loan amount... so i have a table with

id
rate_sheet_id
high_loan_amount
low_loan_amount
adjustment

and what I need to do is test against the high and low loan amount and make an adjustment accordingly... A single sheet may have up to 3 or four of these which is why it is an a seperate table...

Do i run yet another while loop? or is there a single sql query i can run?

jayemvee
02-02-2007, 01:25 AM
Just to clarify.... If the loan amount is between the high and the low... then make adjustment... for example you may have these options avaliable for that program.

So if your loan amount is 300,000 it should subtract .25. I need to know how to find the proper one in this situation

30,000 - 75000 +.75
75,001 - 200,000 0
200,001 - 650,000 -.25

guelphdad
02-02-2007, 01:54 AM
since you are working with data in a database you should not be using any FOR loops whatsoever. you would only use those in code (php, coldfusion etc.) when you are displaying the output of your mysql query.

could you actually show your tables with some sample data and what you are trying to do?

as for the second question you posted, look up the use of CASE in the mysql manual

jayemvee
02-02-2007, 11:53 AM
since you are working with data in a database you should not be using any FOR loops whatsoever. you would only use those in code (php, coldfusion etc.) when you are displaying the output of your mysql query.

could you actually show your tables with some sample data and what you are trying to do?

as for the second question you posted, look up the use of CASE in the mysql manual


Sorry maybe i wrote that incorrectly... Buy yes the foreach is for displaying the data i apologize...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum