0

I need your help. When i run the query as noted below, Im getting the MySQL "error 2013: Lost connection". Im using a server v8.

SELECT CONCAT(UCASE(LEFT(tblpatients.Lname,1)), LCASE(SUBSTRING(tblpatients.Lname,2))) as lname, CONCAT(UCASE(LEFT(tblpatients.mi,1)), LCASE(SUBSTRING(tblpatients.mi,2))) as mi, 
CONCAT(UCASE(LEFT(tblpatients.fname,1)), LCASE(SUBSTRING(tblpatients.fname,2))) as fname, tblpatients.PhoneNum as PhoneNum, 
DATE_FORMAT(tblpatients.Bday,'%m/%d/%Y')as Bday, TIMESTAMPDIFF(YEAR, Bday,CURDATE()) AS pxage, 
tblpatients.PatientID as PatientID, DATE_FORMAT(tblobgyne.obgyneDate,'%m/%d/%Y') as obgyneDate, TIME_FORMAT(tblobgyne.obgyneTime, '%h:%i%p') as obgyneTime, 
tblparity.ParityID, tblobgyne.OBGyneID, tblobgyne.chiefcomplain, tblobgyne.companyname as companyname, 
CONCAT(UCASE(LEFT(tblparity.pxservice,1)), LCASE(SUBSTRING(tblparity.pxservice,2))) as pxservice

FROM tblpatients
JOIN tblparity ON tblpatients.PatientID = tblparity.PatientID
JOIN tblobgyne ON tblparity.ParityID = tblobgyne.ParityID                                               
WHERE obgyneDate >= 03-20-2019 ORDER BY obgyneTime ASC;
Mj Eliad
  • 9
  • 6
  • Does this help: https://stackoverflow.com/questions/10563619/error-code-2013-lost-connection-to-mysql-server-during-query – Bill Karwin Mar 22 '19 at 01:28
  • `03-20-2019` isn't a date - `'2019-03-20'` is something mysql will recognise as a date. If you run `EXPLAIN {query}` and show the output we could see if the tables are correctly indexed for this query. – danblack Mar 22 '19 at 01:59
  • @danblack Hey, thanks alot! i use this instead DATE_FORMAT(tblobgyne.obgyneDate,'%Y/%m/%d') >= '2019-03-20' – Mj Eliad Mar 22 '19 at 02:23
  • Don't use DATE_FORMAT on a date to convert it to a string and then rely on implicit conversion to get it back to a date. Madness (because it prevents index use). `WHERE obgyneDate >= '2019-03-20' ` is perfect. – danblack Mar 22 '19 at 02:25

0 Answers0