On 21-Oct-2002 Prabu Subroto wrote: > > Dear friends, > > > > I am developing a database application for our saleses > > with PHP and MySQL. > > Our sales must call the customers on time. They may > > not be late to call the customers. The may not miss > > the appointment to meet the customer on the telephone > > line. > > But I have a problem to implement the SQL query on > > MySQL DB Engine. > > > > Suppose I have this simple table ("APPOINTMENT" Table) > > : > > > > CUSTID Cont_Pers APPOINTMENT_TIME > > 1 Albert 2002-10-23 13:00:00 > > 2 Sarah 2002-10-24 14:00:00 > > 3 Sandra 2002-10-23 08:00:00 > > ... ... ... > > ... ... ... > > > > I want to display one record which contain the > > appointment which has closest time between the current > > time ( "sysdate()" ) and the APPOINTMENT_TIME. > > > > So each the sales query one record (select) the record > > from this table with application than they will finf > > the record which has the earliest appointment time. > > > > I tried this SQL Query but it doesn't work : > > " > > SELECT * > > FROM Appointment > > WHERE MIN(sysdate()-appointment_time) > > GROUP BY CustID > > " > > > > Please tell me to determine the proper SQL Statement.
SELECT * FROM Appointment WHERE NOW < appointment_time ORDER BY appointment_time LIMIT 1; (I don't understand why you GROUP BY. The SalesRep can only talk to one at a time, right ?) Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. (53kr33t w0rdz: sql table query) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php