下面的查询为我提供了我想要的结果。
SELECT *
FROM PTAddedApp
WHERE PTAddedApp.date BETWEEN '2014-12-01' AND '2015-01-13'
但是,下面的查询给出了0结果或者如果我放下WHERE PTAddedApp.date = 0我得到所有结果with 0000-00-00作为日期值。我有一个按钮捣碎了相当多。任何帮助将不胜感激。日期列具有日期数据类型。
SELECT PTAddedApp.id,
PTAddedApp.family_id,
PTAddedApp.tid,
PTAddedApp.date,
PTAddedApp.rate,
PT_Tutors.first_name,
PT_Tutors.last_name,
PT_Family_Info2.billing_name
FROM PTAddedApp
INNER JOIN PT_Tutors
ON PTAddedApp.tid = CONCAT(PT_Tutors.first_name, ' ',
PT_Tutors.last_name)
INNER JOIN PT_Family_Info2
ON PTAddedApp.family_id = PT_Family_Info2.id
WHERE PTAddedApp.date BETWEEN '2014-12-01' AND '2015-01-13'
ORDER BY PT_Tutors.last_name
答案 0 :(得分:0)
如果您希望包含与PTAddedApp
中的where条件匹配的所有记录以及在联接表中找到的任何其他数据,则以下操作应该可行!
SELECT PTAddedApp.id,
PTAddedApp.family_id,
PTAddedApp.tid,
PTAddedApp.date,
PTAddedApp.rate,
PT_Tutors.first_name,
PT_Tutors.last_name,
PT_Family_Info2.billing_name
FROM PTAddedApp
LEFT JOIN PT_Tutors
ON PTAddedApp.tid = CONCAT(PT_Tutors.first_name, ' ',
PT_Tutors.last_name)
LEFT JOIN PT_Family_Info2
ON PTAddedApp.family_id = PT_Family_Info2.id
WHERE PTAddedApp.date BETWEEN '2014-12-01' AND '2015-01-13'
ORDER BY PT_Tutors.last_name