데이터베이스에 여러 날짜를 쉼표 (,)로 구분하여 한 열에 저장하고 있습니다.
이 날짜로 현재 날짜를 비교하는 방법을 알고 싶습니다. 첫 번째 예에서는 쉽지만 문제는 두 번째 예입니다.
누구든지 나를 도울 수 있습니다 ....?
감사...
그렇게 형편없는 데이터 구조를 가지고 있다면 나는 확실히 find_in_set()
and를 사용할 것입니다 substring_index()
.
select t.*
from t
where find_in_set(date_format(curdate(), '%Y-%m-%d'), datecol) > 0 or
(datecol like '%,%' and datecol not like '%,%,%' and
date_format(curdate(), '%Y-%m-%d') between substring_index(datecol, ',', 1) and substring_index(datecol, ',', -1)
);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다