質問するログイン新規登録

質問編集履歴

2

データの例を追記。

2016/09/22 06:31

投稿

hideki0227
hideki0227

スコア19

title CHANGED
File without changes
body CHANGED
@@ -37,4 +37,42 @@
37
37
  tw_timelineには以下のカラムが、
38
38
  `number`, `id`, `comment`, `date`, `replyto`, `replyfrom`, `quote_from`
39
39
  tw_account_detailには以下のカラムがあります。
40
- `id`, `name`, `prof`, `place`, `filename`, `created_date`, `updated_date`
40
+ `id`, `name`, `prof`, `place`, `filename`, `created_date`, `updated_date`
41
+
42
+ 例えば各テーブルの1レコード目は以下のようなデータがあります。
43
+
44
+ tw_timeline
45
+
46
+ number
47
+ id
48
+ comment
49
+ date
50
+ replyto
51
+ replyfrom
52
+ quote_from
53
+
54
+ 1
55
+ 3
56
+ あいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえお
57
+ 2016-07-25 17:29:25
58
+ 0
59
+ 0
60
+ 0
61
+
62
+ tw_account_detail
63
+
64
+ id
65
+ name
66
+ prof
67
+ place
68
+ filename
69
+ created_date
70
+ updated_date
71
+
72
+ 1
73
+ ひろし
74
+ ひろしの自己紹介2
75
+ 東京2
76
+ e371bda7e8f2c361cb62978106696603.jpg
77
+ 2016-09-19 05:01:36
78
+ NULL

1

テーブルと各テーブル内カラムの名称を追記しました。

2016/09/22 06:31

投稿

hideki0227
hideki0227

スコア19

title CHANGED
File without changes
body CHANGED
@@ -29,4 +29,12 @@
29
29
  WHERE tw_timeline.id = 1 OR tw_timeline.id = 9 OR tw_timeline.id = 10 OR
30
30
  tw_timeline.id = 4 OR tw_timeline.id = 2 OR tw_timeline.id = 3
31
31
  ORDER BY tw_timeline.date DESC
32
- ```
32
+ ```
33
+
34
+ tw_timeline(掲示板の投稿内容一覧)というテーブルがありまして、tw_account_detailというのは投稿者の名前などを格納するテーブルです。
35
+ 同じtw_timelineおよびtw_account_detailのテーブルを2回ずつJOINしているのは、=の右の数値を条件に別の数値を取り出したいためです。
36
+
37
+ tw_timelineには以下のカラムが、
38
+ `number`, `id`, `comment`, `date`, `replyto`, `replyfrom`, `quote_from`
39
+ tw_account_detailには以下のカラムがあります。
40
+ `id`, `name`, `prof`, `place`, `filename`, `created_date`, `updated_date`