I am new in codeigniter and i am trying to join 3 table but it gives some issu

how to run codeigniter project
upgrade codeigniter 3 to 4
codeigniter guidelines
codeigniter welcome page
welcome to codeigniter
codeigniter table of contents
codeigniter 3 support
codeigniter 3.1 9 documentation

I have 3 table like ts_users , ts_acc_category ts_user I am trying to join like this


$this->db->join('ts_users','ts_users.user_id = ts_voucher.id');
$this->db->join('ts_acc_category','ts_voucher.user_id = ts_acc_category.acc_cat_id');


And error is

<h1>A Database Error Occurred</h1>
        <p>Error Number: 1054</p><p>Unknown column 'ts_voucher.user_id' in 'on clause'</p><p>SELECT *
FROM `ts_voucher`
JOIN `ts_users` ON `ts_users`.`user_id` = `ts_voucher`.`id`
JOIN `ts_acc_category` ON `ts_voucher`.`user_id` = `ts_acc_category`.`acc_cat_id`
WHERE `user_reg_type` = 'bill_party'</p><p>Filename: models/reports/ExpensesModel.php</p><p>Line Number: 32</p> </div>

Please tell me where i am wrong in my code

=>Try this..

$this->db->select('tv.*,tu.*,tac.*'); //select field what you might want to select. 
        $this->db->from('ts_voucher as tv');
        $this->db->join('ts_users tu','tu.user_id = tv.id', 'left');
        $this->db->join('ts_acc_category as tac','tv.user_id = tac.acc_cat_id', 'left');

Problem with multiple joins, I'm new to Code Igniter, and so far love it. However, I'm having issues when using multiple join statements in my functions. And it only worked with 3 joins once I added the 'LEFT' to each of the joins. I can't find any answers. the events table event_id you might have a problem because now you're trying� Join Query Using Codeigniter. This tutorial will help you to learn join query using php codeigniter. Table joins are essential part in application development while displaying the records from multiple tables. So lets have a closer look.

you don't user_id field in your ts_voucher table please check that first

Issue joining tables and running loops, First of all, to everyone who has contributed to this forum and the such as doctrine but I am finding it difficult getting it working with CI. 3: run the query I need some support regarding how I can now run a foreach loop that assigns an extra-dimensioned array, and then returning that new construct to� In other words, if you’re going to combine two tables, how can you use the left join in Codeigniter or the right join in Codeigniter, we discuss that how can you do this using CodeIgniter. Today’s I am going to show you how to use joins in ci, so here is Codeigniter joins .

$this->db->select('tv.*,tu.*,tac.*'); //select field what you might want to select. 
        $this->db->from('ts_voucher as tv');
        $this->db->join('ts_users tu','tu.user_id = tv.id', 'left');
        $this->db->join('ts_acc_category as tac','tv.user_id = tac.acc_cat_id', 'left');

Change Log — CodeIgniter 3.1.11 documentation, Fixed a bug (#5651) - Database Caching could try to delete non-existent cache Fixed byte-safety issues in Encrypt Library (DEPRECATED) when Bug fixes for 3.1.3� Fixed a bug (#4863) - HTML Table Library method set_caption() was missing Added a new tempdata feature that allows setting userdata items with � I am gonna use CodeIgniter's active record class to generate Join Queries in this tutorial. Because by using AR class we can write complex joins very easily and a major benefit to using the Active Record features is that it allows you to create database independent applications since the query syntax is generated by each database adapter.

Insert and Update database checking, I want know if I insert (or update) some data into tables, should I (12-26-2015, 12:14 PM)pb.sajjad Wrote: I'm using CI3 and its query If you wish to check for errors, CodeIgniter has $this->db->error(), Actually handing errors in PHP involves try/catch. INNER JOIN users u2 ON glists.owner = u2.id Dari table-table diatas : Dengan mempuyai Id yang sama yaitu Id(tbrakyat) = Id(tbsekolah) dan Idpendidikan(tbsekolah) = Idpendidikan(tbstatus) Di sini saya akan menampilkan Join 2 Table terlebih dahulu, Kita langsung saja untuk membuat model, Controler dan Viewnya, untuk settingan dasar seperti Config, route, database bisa kalian cara i Google sendiri ^_^

mysqli::query - Manual, Below I am trying to join a user id with a user role. in the first table (tbl_usr), role is a number and in the second is a text name (tbl_memrole is a lookup table). If I� See the first few StackOverflow article results here for some good information. An ORM might have some built-in solution that helps keep your code clean, but essentially does either multiple queries or a transaction. That's an option, but I don't know of any specific ORMs that do this off the top of my head (I am unfamiliar with most of them).

session_start - Manual, session_start — Start new or resume existing session This function returns TRUE if a session was successfully started, otherwise FALSE . This error has been reported to PHP HQ, but they've marked it "Won't fix" because they -3. anon at ymous dot com �. 9 years ago. I am trying to get a session created by a browser� This table is used for logging in. ID | login_id | role | password ---+-----+-----+----- 1 | 1110QA | admin | password 2 | 1110QB | teacher | password 3 | 1110QC | teacher | password And this is my second table which is the teacher table. And this table is where I will get the information of the teacher like her name.

  • field user_reg_type which table to belong
  • in ts_users table
  • In the join between users and vouchers, you try to use `ts_voucher`.`id`; in the next join, I see `ts_voucher`.`user_id`.
  • two field are there in table of ts_voucher so also i add two diffrent id used in join ):
  • i also tell that @KhanMuntazar share your table structure so we can esay to solved their problem
  • sorry i'm not understand what you say
  • the error says you dont have the user_id field in your ts_voucher table .if possible can you share the table structure in the question
  • table structure is upload please check
  • you have to create a new field in ts_voucher i.e user_id and save the user_id there also.After that only you can get the records
  • know it gives me this error <p>Error Number: 1054</p><p>Unknown column 'ts_voucher.user_id' in 'on clause'</p>
  • give me name of id ts_voucher table check proper database field name
  • ts_voucher id name is "id"
  • check edited answer & in db record are there or not in ts_users
  • yeppp bro (: (: