[thelist] php. finding order
sbeam
sbeam at onsetcorps.net
Mon Jan 17 10:31:59 CST 2005
On Monday 17 January 2005 09:17 am, Murat Tutumlu wrote:
> I have a table in MySql database. It has student_no,
> Grade, Lesson, and Visa1 columns. I want to echo a
> definite student's order in Visa1 at the same grade
> and for the same lesson.
>
> some thing like that:
> You are #.th in your class For Visa 1 in Biology
> lesson
If you are using mySQL >4.1 then this calls for a subselect. I'm
assuming Visa1 is a numeric field of some kind, if not then it gets
more complicated.
SELECT COUNT(*) FROM table WHERE Visa1 > (SELECT Visa1 FROM table WHERE
student_no = XXXXX) AND Grade = X and Lesson = X)
If you are stuck with old mySQL then of course, in your application
layer, just get the Visa1 value for a given student and replace the
subselect clause above with that.
--
# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/
More information about the thelist
mailing list