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

質問編集履歴

3

fix

2019/05/31 19:14

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
File without changes

2

fix

2019/05/31 19:14

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -33,7 +33,7 @@
33
33
  以下のSQLを実行すると結果が0件になります。
34
34
  ```sql
35
35
  select * from items i where i.id in (
36
- select JSON_EXTRACT(item, '$.item_ids') from weapons w where w.id=1;
36
+ select JSON_EXTRACT(item, '$.item_ids') from weapons w where w.id=1
37
37
  );
38
38
  ```
39
39
  おそらく、IN句にJSONの文字列データが渡されている為0件になっています。

1

fix

2019/05/31 18:58

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -17,7 +17,7 @@
17
17
  ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
18
18
 
19
19
  INSERT INTO `weapons` (`id`, `item`) VALUES
20
- (1, '[1,2]');
20
+ (1, '{"item_ids":[1,2]}');
21
21
  ```
22
22
 
23
23
  # やりたい事
@@ -33,7 +33,7 @@
33
33
  以下のSQLを実行すると結果が0件になります。
34
34
  ```sql
35
35
  select * from items i where i.id in (
36
- select JSON_EXTRACT(item, '$') from weapons w where w.id=1
36
+ select JSON_EXTRACT(item, '$.item_ids') from weapons w where w.id=1;
37
37
  );
38
38
  ```
39
39
  おそらく、IN句にJSONの文字列データが渡されている為0件になっています。