遭遇例3

MySQL用語集

カテゴリー: エラー  閲覧数:220 配信日:2019-01-19 20:49


エラー修正内容


body を ANY_VALUE(`body`) AS body へ修正

エラー修正前


    public function fetchByStateid2($state_id)
   {
       $sql = "
SELECT        
a.id AS id,
a.category_id AS category_id,
a.state_id AS state_id,
a.body AS body,
a.created_at AS created_at,
a.modified AS modified,
topic_name,
r.body AS rbody,
r.modified AS rmodified,
u.display_name, u.site_id, c.category, s.situation, s.color,relationentrynum
     
FROM
status AS a

LEFT JOIN user u ON a.user_id = u.id
LEFT JOIN category c ON a.category_id = c.category_id
LEFT JOIN state s ON a.state_id = s.state_id

LEFT OUTER JOIN(
SELECT
topic_id,body, MAX(modified) AS modified, COUNT(topic_id) AS `relationentrynum`

FROM
res
GROUP BY topic_id
) AS r ON a.id = r.topic_id
       

 
               WHERE a.state_id =:state_id
                   AND public = 1
ORDER BY created_at DESC
       ";

// echo $sql;


       return $this->fetchAll($sql, array(
           ':state_id'        => $state_id,

       ));
   }      


エラー修正後


    public function fetchByStateid2($state_id)
   {
       $sql = "
SELECT        
a.id AS id,
a.category_id AS category_id,
a.state_id AS state_id,
a.body AS body,
a.created_at AS created_at,
a.modified AS modified,
topic_name,
r.body AS rbody,
r.modified AS rmodified,
u.display_name, u.site_id, c.category, s.situation, s.color,relationentrynum
     
FROM
status AS a

LEFT JOIN user u ON a.user_id = u.id
LEFT JOIN category c ON a.category_id = c.category_id
LEFT JOIN state s ON a.state_id = s.state_id

LEFT OUTER JOIN(
SELECT
topic_id,ANY_VALUE(`body`) AS body, MAX(modified) AS modified, COUNT(topic_id) AS `relationentrynum`

FROM
res
GROUP BY topic_id
) AS r ON a.id = r.topic_id
       

 
               WHERE a.state_id =:state_id
                   AND public = 1
ORDER BY created_at DESC
       ";

// echo $sql;


       return $this->fetchAll($sql, array(
           ':state_id'        => $state_id,

       ));
   }      


指定期間人気ページランキング / 2020-5-28 → 2025-4-24
順位 ページタイトル抜粋 アクセス数
1 #1241 - オペランドに 1 個の列が必要です。 | エラー 3601
2 MySQL用語 1560
3 SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry | エラー 1356
4 クエリエラー: #1265 - 列 'カラム名' の 行 ★ でデータが切り捨てられました。 | エラー 1335
5 ( ! ) Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value | エラー 927
6 Data truncated for column | エラー 608
7 where clause is ambiguous | エラー 600
8 Incorrect integer value | エラー 582
9 クエリエラー: #1294 - 列 'カラム名' に ON UPDATE旬は無効です。 | エラー 567
10 <> | 演算子 477
11 スキーマ | データベースの構造 451
12 インデックス | 最適化 407
13 #1067 - Invalid default value for 'id' | エラー 389
14 SELECT list is not in GROUP BY clause and contains nonaggregated column | エラー 265
15 #3106 - 'Fulltext index on virtual generated column' is not supported for generated columns. | エラー 245
16 問題発生 / ハマった点 / indexを確認 243
17 エラーメッセージ / エラー原因 / エラー対応 239
18 遭遇例1.INT型カラムに空文字INSERT 238
19 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ★★ at line △△ | エラー 233
20 phpMyAdmin上で、VARCHARデータ型カラム を FLOATデータ型カラム へ変更しようとしたら、エラー発生 228
2025/4/25 1:01 更新