-2

I'm implement select query in codeigniter application.

But it shows the below error.

A Database Error Occurred
Error Number: 1054

Unknown column 'Ak3456' in 'where clause'

SELECT * FROM `table` WHERE `Ak3456` IS NULL

Filename: C:/wamp/www/application/system/database/DB_driver.php

Line Number: 691

My select query is

$data = $this->db->get_where('table',$number);

Please any one help me to solve this problem.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • Possible duplicate of [Unknown column in 'field list' error on MySQL Update query](https://stackoverflow.com/questions/1346209/unknown-column-in-field-list-error-on-mysql-update-query) – SmrtGrunt May 24 '19 at 12:43

2 Answers2

3

The proper syntax is

// replace table with your table name and field_name with for which value  
//you want to search for Ak3456
$data = $this->db->get_where('table',['field_name' => 'Ak3456']); 

Doc link.

Syntax

get_where([$table = ''[, $where = NULL[, $limit = NULL[, $offset = NULL]]]])

Parameters

  • $table (mixed) – The table(s) to fetch data from; string or array
  • $where (string) – The WHERE clause
  • $limit (int) – The LIMIT clause
  • $offset (int) – The OFFSET clause

Returns: CI_DB_result instance (method chaining)

Return type: CI_DB_result

Rahul
  • 18,271
  • 7
  • 41
  • 60
1

In codeigniter select query structure is below,

$this->db->get_where('table_name',['feild_name'=>'value']);

So you can provide where data as in array type

For example,

$data = $this->db->get_where('table',array('feild_name' => $number));

CreativeMinds
  • 333
  • 3
  • 22