Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はMysqlの初心者です。馬のテーブルから10歳以上の馬を見つけるのに助けが必要です。このテーブルは、「生まれ」と「死んだ」の年のみの列で構成されています。たとえば、生まれ(1986)死(1998)などです。 )。
サラブレッド馬は、誕生年の1月1日に生まれたものとみなされます。したがって、正しい答えを得るには単純な減算が必要です。
select horse_name from horses where born < (year(current_date) - 10) and died is null;
本当に 10 歳以上の馬を検索する場合は、演算子を「<」から「<=」に変更します。