回答編集履歴

3

変更

2016/10/15 11:34

投稿

A.Ichi
A.Ichi

スコア4070

test CHANGED
File without changes

2

変更

2016/10/15 11:34

投稿

A.Ichi
A.Ichi

スコア4070

test CHANGED
@@ -23,3 +23,27 @@
23
23
  print_r ($rec);
24
24
 
25
25
  ```
26
+
27
+
28
+
29
+ 上記の例題を見て修正してみました
30
+
31
+ ```sql
32
+
33
+ $sql1 = $wpdb->prepare("
34
+
35
+ SELECT * FROM $wpdb->zaimumaster t4 JOIN
36
+
37
+ (SELECT id,xki,secid FROM $wpdb->zaimumaster t1
38
+
39
+ JOIN (SELECT secid, max(intperiod) intperiod FROM $wpdb->zaimumaster) t2
40
+
41
+ USING( secid,intperiod ) WHERE secid=%d
42
+
43
+ ) t3 USING (id,xki,secid);
44
+
45
+ ",$secid);
46
+
47
+ ```
48
+
49
+

1

修正

2016/10/15 11:34

投稿

A.Ichi
A.Ichi

スコア4070

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  $secid=100;
8
8
 
9
- $stmt = $wpdb->prepare("select * from Atable t1 join (select secid, max(sales) sales from Atable group by secid) t2 using(secid,sales) where t1.secid=:secid");
9
+ $stmt = $wpdb->prepare("select t1.* from Atable t1 join (select secid, max(sales) sales from Atable group by secid) t2 using(secid,sales) where t1.secid=:secid");
10
10
 
11
11
  $stmt->bindValue(':secid',$secid));
12
12