$query = " SELECT * FROM fault,fault_register,member
WHERE member.member_key='".$member_detail->member_key."'
AND fault_register.member_key=member.member_key
AND fault_register.fault_key=fault.fault_key
AND fault_register.fault_regis_date "; //คำสั่ง SQL
ใส่แบบนี้มันไม่errorแต่ค้นหาไม่ออก Code (PHP)
$query.= ( ($startDate != '') && ($endDate != '') ) ? " AND fault_regis_date BETWEEN '$startDate' AND '$endDate' " : "";
SELECT * FROM fault, fault_register, member WHERE member.member_key='547d51af41a0079521d6eb14f9685a72' AND falut_register.member_key=member.member_key AND falut_register.fault_key=fault.fault_key AND fault_register.fault_register_date BETWEEN '2019-06-06' AND '2019-06-06'
ไม่ได้ครับ ขึ้น ERROR
SELECT * FROM fault, fault_register, member WHERE member.member_key='547d51af41a0079521d6eb14f9685a72' AND falut_register.member_key=member.member_key AND falut_register.fault_key=fault.fault_key AND fault_register.fault_register_date BETWEEN '2019-06-06' AND '2019-06-06' LIMIT 0, 25
MySQL said: Documentation
#1054 - Unknown column 'falut_register.member_key' in 'where clause'
ไม่ออกครับ
ไม่พบรายการค้นหา [ SELECT * FROM fault,fault_register,member WHERE member.member_key='dc1c2ff6c3f320e32f6929da23aa104f' AND fault_register.member_key=member.member_key AND fault_register.fault_key=fault.fault_key AND fault_register.fault_regis_date AND fault_register.fault_regis_date BETWEEN '2019-06-06' AND '2019-06-06' ]
ผมลองแบบนี้ออกนะแต่เพี้ยน 555 Code (PHP)
$query.= ( ($startDate != '') && ($endDate != '') ) ? " AND fault_register.regis_key=fault_register.fault_regis_date BETWEEN '$startDate' AND '$endDate' " : "";
SELECT * FROM fault, fault_register, member
WHERE member.member_key='547d51af41a0079521d6eb14f9685a72'
AND falut_register.member_key=member.member_key
AND falut_register.fault_key=fault.fault_key
AND (fault_register.fault_register_date BETWEEN '2019-06-06' AND '2019-06-06')
LIMIT 0, 25
SELECT * FROM fault,fault_register,member WHERE member.member_key='dc1c2ff6c3f320e32f6929da23aa104f' AND fault_register.member_key=member.member_key AND fault_register.fault_key=fault.fault_key AND fault_register.fault_regis_date BETWEEN '2019-06-06' AND '2019-06-06'
SELECT *
FROM fault F1,fault_register FR, member MB
WHERE MB.member_key='dc1c2ff6c3f320e32f6929da23aa104f'
AND FR.member_key=MB.member_key
AND FR.fault_key=F1.fault_key AND fault_register.fault_regis_date ตรงนี้เอาออก AND FR.fault_regis_date BETWEEN '2019-06-06' AND '2019-06-06'
สีแดง FR.fault_regis_date มี TYPE เป็น DATETIME หรือ DATE
ถ้าเป็น datetime
AND FR.fault_regis_date BETWEEN '2019-06-06 00:00:00' AND '2019-06-06 23:59:59'
หรือ
AND date(FR.fault_regis_date) = '2019-06-06'