How can I select and display the maximum (and minimum) values from among
several fields in a single record in mysql using php
I have a table which lists several tours and for each tour there are
several categories of accommodation types with different prices, along
with a lot of other fields such as dates, deadlines etc. It was easy to
set things up to display the array showing the tour, dates, deadlines but
I also want to select and display the maximum (and minimum when not 0)
accommodation rates for each tour. I may not be understanding some of the
answers I'm seeing but most seem to be looking for max values within a
field rather than across fields. I'm assuming once I know how to find the
max value, finding the min value would be the same basic procedure.
the abbreviated table structure with example data is:
id tourID RmA RmB RmC RmD ...other fields...
1 mb 600 450 550 300
2 kr 900 0 600 450
3 ww 500 650 550 600
4 wf 750 300 400 500
What I'd like to add to my current display is:
Tour Rates
mb 300 - 600
kr 450 - 900
WW 500 - 650
wf 300 - 750
I apologise if I'm repeating a frequently asked question, but it may be
that I haven't googled my question in a manner to find the appropriate
answer.
No comments:
Post a Comment