• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
unable to fetch records from database

#1
Hi
whats wrong in my following query. i got the error
Error Number: 1054
Unknown column 't.user_id' in 'where clause'
-------------------------my query------------

function ShowTransData($data){
$this->db->select('*')
->from('transaction')
->join('user', 'transaction.user_id = user.user_id')
->where('t.user_id='. $data);
$query = $this->db->get();
return $query->result();
Reply

#2
(01-06-2016, 02:16 AM)nady Wrote: Hi
whats wrong in my following query. i got the error
Error Number: 1054
Unknown column 't.user_id' in 'where clause'
-------------------------my query------------

function ShowTransData($data){
$this->db->select('*')
->from('transaction')
->join('user', 'transaction.user_id = user.user_id')
->where('t.user_id='. $data);
$query = $this->db->get();
return $query->result();

You are trying to get `t.user_id` but you have not assigned `t` to the `transaction` column

PHP Code:
function show_trans_data($data){
    
$this->db->select('*')
    ->
from('transaction as t')
    ->
join('user''t.user_id = user.user_id')
    ->
where('t.user_id'$data); // I'm guessing this is just an ID number?

    
$query $this->db->get();

    return 
$query->result();


I also tidied up your function.
Reply

#3
Try the following code:


PHP Code:
function show_trans_data($data){
 
   $this->db->select('*')
 
   ->from('transaction as t')
 
   ->join('user''t.user_id = user.user_id')
 
   ->where('t.user_id = "' $t.user_id '"');

 
   $query $this->db->get();

 
   return $query->result();

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.