Hello all
i have a table which contains percentages of subjects.
i.e
id | a | b | c | d
1 | 15|20 |40 | 23
Now i have another record which have subject c highest value i.e c=35
i want to match it against the the other records which have in the range of 7 less than and 7 greater than the highest value
(where 7<c>7 ).
how can i make query to get the matching records.
sample query is
$query="select id from percent where (subject c is in the range less than 7 and greater than 7)
in my case if c=35 than this query should return the record with id 1 cause (7 greater than c) c=35+7=42 and in record with
id 1 has c=40
Wouldn’t it be better to normalize that table? (id, subjectid, percentage)
Now i have another record which have subject c highest value i.e c=35
Another record? Where? Same table, other table, user input?
yes another record is of same table. why i am not normalize cause this table already contain a foreign key st_id
What is st_id?
How do you identify the row with the max c value to use?
okay i posted all the db design.
i have a student table(st_id, name …)
and percent table (id, subject a, b, c,d, st_id)
now first i search the percent table for specific student
$query="SELECT a, b, c,d
FROM percent
WHERE st_id =1";
$rs=mysql_query($query) or die(mysql_error());
$row=mysql_fetch_assoc($rs);
arsort($row);
$keys = array_keys ($row);
This will find the highest percentage and its value
now my question is how can i find the match which is in the range 7 less and 7 greater than
WHERE c > 35 - 7
AND c < 35 + 7