how to fix error SQLSTATE[42S22]: Column not found

how to fix error SQLSTATE[42S22]: Column not found

9kitti9kitti Posts: 1Questions: 1Answers: 0

how to fix SQLSTATE[42S22]: Column not found but my table have this column
my table

CREATE TABLE `send_nosend`  (
  `ID_column` int(255) NOT NULL PRIMARY KEY,
  `ID_CHANGWAT` int(255) NOT NULL,
  `CHANGWAT_NAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `AMPHUR_NAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `HSUB_NAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `HMAIN_OP` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `HMAIN_OP_NAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `HSUB_CODE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `SUBTYPE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `TYPE_DESC` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `sendcount` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `TUMBON_NAME` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `statussend` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`ID_column`, `ID_CHANGWAT`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Compact;

my setting on server.php

$columns = array(
    array( 'db' => 'CHANGWAT_NAME', 'dt' => 0 ),
    array( 'db' => 'AMPHUR_NAME',  'dt' => 1 ),
    array( 'db' => 'HSUB_NAME',   'dt' => 2 ),
    array( 'db' => 'sendcount', 'dt' => 3,),
    array( 'db' => 'statussend','dt' => 4,
        'formatter' => function( $d, $row ) {
            return date( 'd-m-Y', strtotime($d));
        }
    )  
);

but show error on input value input box for search

SELECT `CHANGWAT_NAME`, `AMPHUR_NAME`, `HSUB_NAME`, `sendcount`, `statussend`
             FROM `send_nosend`


             LIMIT 0, 10{"error":"An SQL error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'sendcount' in 'field list'"}

help me please.

Answers

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    The SQL query being executed looks really straight forward, which suggests to me that perhaps you might be connected to the wrong database? Perhaps do a SHOW COLUMNS FROM ... using the same database connection to confirm the column names.

    Allan

Sign In or Register to comment.