[前][次][番号順一覧][スレッド一覧]

mysql:13119

From: "片寄白王" <"片寄白王" <katayose@xxxxxxxxxx>>
Date: Wed, 28 Jun 2006 14:24:10 +0900
Subject: [mysql 13119] Re: 日付型・日付時刻型の比較について

片寄と申します。

CAST()の使用目的がわかりません。
必要なのでしょうか?

SELECT * FROM hiduke_tb WHERE hiduke >= CAST('2006-06-01' AS date)
SELECT * FROM hiduke_tb WHERE hiduke >= CAST('2006-06-1' AS date)
SELECT * FROM hiduke_tb WHERE hiduke >= CAST('2006-6-1' AS date)

であるなら、ちょっとは理解できますが


片寄

Akimasa wrote:
> 初めまして、大月と申します。
> 
 
> mysql> SELECT * FROM hiduke_tb WHERE hiduke >=
> 2006-6-1';  ------------------(1)
> +------------+
> | hiduke     |
> +------------+
> | 2006-06-01 |
> | 2006-06-10 |
> +------------+
> 2 rows in set (0.00 sec)
> 
> mysql> SELECT * FROM hiduke_tb WHERE CAST(hiduke AS date) >=
> 2006-6-1';  ----(2)
> Empty set (0.00 sec)
> 
> mysql> SELECT * FROM hiduke_tb WHERE CAST(hiduke AS date) >=
> 2006-06-1';  ---(3)
> +------------+
> | hiduke     |
> +------------+
> | 2006-06-10 |
> +------------+
> 1 row in set (0.00 sec)
> 
> mysql> SELECT * FROM hiduke_tb WHERE CAST(hiduke AS date) >=
> 2006-06-01';  --(4)
> +------------+
> | hiduke     |
> +------------+
> | 2006-06-01 |
> | 2006-06-10 |
> +------------+
> 2 rows in set (0.00 sec)
> 
> ※(2)(3)(4)は、わざと日付型から日付型にCASTしています


[前][次][番号順一覧][スレッド一覧]

     13118 2006-06-28 13:20 ["Akimasa" <asamika2o] 日付型・日付時刻型の比較について        
->   13119 2006-06-28 14:24 ┣["片寄白王" <katayose]                                       
     13120 2006-06-28 14:50 ┃┗["Akimasa" <asamika2o]                                     
     13122 2006-06-28 16:13 ┃ ┗["片寄白王" <katayose]                                   
     13123 2006-06-28 16:29 ┃  ┗["Akimasa" <asamika2o]                                 
     13124 2006-06-28 17:16 ┃   ┗["片寄白王" <katayose]                               
     13125 2006-06-28 17:32 ┃    ┗["Akimasa" <asamika2o]                             
     13126 2006-06-28 17:48 ┗[SUGAWARA Hajime <sug]                                       
     13127 2006-06-28 18:37  ┗["Akimasa" <asamika2o]                                     
     13128 2006-06-28 19:16   ┗[SUGAWARA Hajime <sug]                                   
     13129 2006-06-28 19:49    ┣[<milk_coffee_2004jp@]                                 
     13130 2006-06-28 22:48    ┗["Akimasa" <asamika2o]