0

I got the "SQL Error (1054): Unknown column 'xxxxx' in 'field list'uery"

My Query :

SELECT 
`baab`.`department` as `Department`,
`baab`.`section` as `Section`,
`baab`.`period` as `Periode`,
`baab`.`id` as `ID`,
`baab`.`cip_id` as `CIP ID`,
`baab`.`no_baab` as `Nomor BAAB`,
`cip`.`invoice_number` as `Nomor Invoice`,
`cip`.`label_bc` as `Label BC`,
`cip`.`price` as `@Harga`,
`baab`.`date_service` as `Tanggal Pemakaian`,
-- `baab.asset_name_user` as `Asset Name (User)`,
`baab`.`location` as `Lokasi`,
`baab`.`condition` as `Kondisi`,
`baab`.`status` as `Status`,
`baab`.`created_by` as `Dibuat Oleh`,
-- `baab`.`commited_by` as `Dicek Oleh`,
`baab`.`verified_by` as `Diverifikasi Oleh`,
`baab`.`created_at` as `Dibuat Tanggal`,
-- `baab`.`commited_at` as `Dicek Tanggal`,
`baab`.`verified_at` as `Diverifikasi Tanggal`
FROM `t_baab` `baab` JOIN `t_cip` `cip` ON `baab`.`cip_id` = `cip`.`id`
WHERE `baab`.`status` IN('PREPARED', 'CHECKED', 'APPLIED', 'CHECKED-1', 'CHECKED-2') AND `baab`.`section` = 'MTC'
ORDER BY `created_at` ASC

thoose commented lines will throw "unknown column" issues, but i'm pretty sure that those column exists,

Here's the table structure :

+-----------------------+--------------+------+-----+-------------------+-----------------------------+
| Field                 | Type         | Null | Key | Default           | Extra                       |
+-----------------------+--------------+------+-----+-------------------+-----------------------------+
| id                    | int(11)      | NO   | PRI | NULL              | auto_increment              |
| period                | char(7)      | YES  |     | NULL              |                             |
| department            | varchar(50)  | NO   |     | NULL              |                             |
| section               | varchar(50)  | NO   |     | NULL              |                             |
| cip_id                | int(11)      | NO   |     | NULL              |                             |
| cip_yiras             | int(11)      | NO   |     | NULL              |                             |
| no_baab               | varchar(50)  | YES  |     | NULL              |                             |
| baab_qr               | varchar(255) | YES  |     | NULL              |                             |
| asset_name_user       | varchar(255) | NO   |     | NULL              |                             |
| date_service          | char(10)     | NO   |     | NULL              |                             |
| life_use              | int(11)      | NO   |     | NULL              |                             |
| location              | varchar(50)  | NO   |     | NULL              |                             |
| condition             | varchar(50)  | NO   |     | NULL              |                             |
| asset_category_orafin | varchar(50)  | NO   |     | NULL              |                             |
| serial_number         | varchar(191) | NO   |     | NULL              |                             |
| manufacturing_date    | char(10)     | NO   |     | NULL              |                             |
| remarks               | varchar(255) | YES  |     | NULL              |                             |
| photo                 | varchar(255) | YES  |     | NULL              |                             |
| status                | char(10)     | NO   |     | PREPARED          |                             |
| created_by            | char(3)      | NO   |     | NULL              |                             |
| commited_by           | char(3)      | NO   |     | NULL              |                             |
| verified_by           | char(3)      | YES  |     | NULL              |                             |
| created_at            | timestamp    | NO   |     | CURRENT_TIMESTAMP |                             |
| commited_at           | timestamp    | YES  |     | NULL              |                             |
| verified_at           | timestamp    | YES  |     | NULL              |                             |
| updated_at            | timestamp    | YES  |     | NULL              | on update CURRENT_TIMESTAMP |
+-----------------------+--------------+------+-----+-------------------+-----------------------------+

How can i solve this ?

owf
  • 245
  • 1
  • 9
  • 26

1 Answers1

0

Maybe the error is arising because you're somewhere referring to something that is not actually a Column. Check this. Might be helpful : Unknown column in 'field list' error on MySQL Update query

What it says is try using different quotes.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Gourav Singh Rawat
  • 421
  • 1
  • 7
  • 17