PHPを使って、ユニークな属性の二つの列を統合する方法について教えてください。
下記はテーブルのサンプルを出力したものです。
lang
1user_name| entry_type | entry_datetime 2User1 | Time In | 14-03-28 16:40:40 3User1 | Time Out | 14-03-28 16:40:41 4User2 | Time In | 14-03-28 16:41:13 5User2 | Time Out | 14-03-28 16:41:15 6User1 | Time In | 14-03-27 16:42:30 7User1 | Time Out | 14-03-27 16:42:34 8User2 | Time In | 14-03-27 16:43:32 9User2 | Time Out | 14-03-27 16:43:35
以下のクエリを使いました。
lang
1SELECT tir.user_name, tir.entry_name, MAX(tir.entry_datetime) AS date 2FROM time_registers AS tir 3GROUP BY tir.entry_type, tir.user_name 4
結果は下記のようになりました。
lang
1user_name| entry_type | entry_datetime 2User1 | Time In | 14-03-28 16:40:40 3User1 | Time Out | 14-03-28 16:40:41 4User2 | Time In | 14-03-28 16:41:13 5User2 | Time Out | 14-03-28 16:41:15
同じユーザ名を1つのラインに統合して次のようにアウトプットする方法はありますか?
lang
1user_name| Date | Timein | Timeout 2User1 | 13-03-28 | 16:40:40 | 16:40:41 3User2 | 13-03-28 | 16:41:13 | 16:41:15
どうしたらいいのか分かりません。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。