|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Can anyone tel why the statement
MYSQL_QUERY("SELECT MAX(dateUpdate) AS dateUpdate FROM organisatie") does not produce the same result as MYSQL_QUERY("SELECT * FROM organisatie WHERE dateUpdate = (SELECT MAX(dateUpdate) FROM organisatie)") The first one gives met the correct last dateUpdate but i want to get not just the date from that record but all the information i contains. What am i doing wrong. Harry |
|
#2
|
|||
|
|||
|
Harry,
Your first query will give you the MAX date over all the records you have on your table. MYSQL_QUERY("SELECT MAX(dateUpdate) AS dateUpdate FROM organisatie") Your second query is giving you any number of results that match the highest date. MYSQL_QUERY("SELECT * FROM organisatie WHERE dateUpdate = (SELECT MAX(dateUpdate) FROM organisatie)") So if your max date is April 20 and you have several records that have this date, you will get them and the results will be different. The question is, what exactly do you want? Note: You are missing the field name you need for your function: MYSQL_QUERY("SELECT * FROM organisatie WHERE dateUpdate = (SELECT MAX(dateUpdate) AS dateUpdate FROM organisatie)") I'm not sure if that's what you are looking for either... Gil |
|
#3
|
|||
|
|||
|
find max
$q_pns = "select max(tmt_golongan) maks from riwayat_golongan1 group by nip order by nip";
$h_pns = mysql_query($q_pns); $pns = mysql_fetch_array($h_pns); $temp = $pns[maks]; $all_pns = "g1.tmt_golongan in ('$temp') and"; i have problem with the program above. i want the $temp contains all the "maks" value, since the $all_pns only contains some maks value but i have no idea what to do. actually i can solve the problem using select ...where tmt_golongan=(select...), but mysql doesn support the function, and i'm not going to use the newest mysql at this moment. thx n sorry for my english |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > Problems with SELECT MAX() |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|