SELECT DISTINCT SBI.salonID, SBI.salonKanjiName, SBI.salonKanaName, SBI.zipCode, SBI.addressCode, SBI.administrativeDiv, SBI.address, SBI.buildingName, SBI.telNo, SBI.faxNo, SBI.webSiteURL, SBI.businessHours, SBI.holiday, SBI.parking, SBI.access, SBI.latitude, SBI.longitude, SBI.chargePersonKanjiName, SBI.chargePersonKanaName, SBI.chargePersonTelNo, SBI.planDiv, SBI.basicCharge, SBI.paymentMethodDiv, SBI.logicalDeleteFlag, SBI.insertDateTime, SBI.updateDateTime, SBI.planDiv, SPI.topImageFileName, SPI.catchCopy, SG.grapeVineNumber, SM.menuNumber, SPI.ownerImageFileName, SPI.topImageContent, SPI.reservationUseFlag FROM TIYS_SalonLogin SL, TIYS_SalonPageInformation SPI, TIYS_SalonBasisInformation SBI LEFT JOIN TIYS_CityTownVillage CTV ON CTV.cityTownVillageID=SBI.cityTownVillageID AND CTV.logicalDeleteFlag='0' LEFT JOIN ( SELECT SGV.salonID, COUNT(*) grapeVineNumber FROM TIYS_SalonGrapevine SGV, TIYS_SalonBasisInformation SBI WHERE SGV.logicalDeleteFlag = '0' AND SBI.salonID = SGV.salonID AND SBI.planDiv = '2' AND SGV.recognizeFlag = '1' GROUP BY SGV.salonID ) SG ON SG.salonID=SBI.salonID LEFT JOIN ( SELECT AL.salonID, COUNT(*) accessNumber FROM TIYS_AccessLog AL WHERE AL.logicalDeleteFlag = '0' AND AL.accessDateTime > DATE_ADD(now(), INTERVAL -30 DAY) GROUP BY AL.salonID ) AL ON AL.salonID=SBI.salonID LEFT JOIN ( SELECT salonID, COUNT(*) menuNumber FROM TIYS_SalonMenuCategory SMC WHERE SMC.openFlag = '1' AND SMC.logicalDeleteFlag = '0' GROUP BY salonID ) SM ON SM.salonID=SBI.salonID WHERE SBI.logicalDeleteFlag='0' AND SL.salonID=SBI.salonID AND SL.recognizeFlag='1' AND SL.logicalDeleteFlag='0' AND SPI.openFlag='1' AND SPI.logicalDeleteFlag='0' AND SPI.salonID=SBI.salonID AND SBI.administrativeDiv IN ('01') ORDER BY pickUpFlag DESC,planDiv DESC,updateDateTime DESC
SQL Query failed