Home>

Use each id in table a to query the information of this id in people table.The statement is as follows:

$this->db->from ("a");
$this->db->join ("b", "sites.id=b.id");

Use each id in table a to query the information of this id in table b.

Note the SQL convention, if a column name is duplicated in two tables,You need to put the table name and a "." Before the column name. So sites.id in the location table means that the table where id is is sites. When performing SQL multi-table query,It ’s best to uniquely identify the column names,This will avoid ambiguity,You can also make yourself clear.

Example:You execute the following statement

$this->db->select ("*");
$this->db->from ("blogs");
$this->db->join ("comments", "comments.id=blogs.id");
$query=$this->db->get ();

Is equivalent to executing this sql statement

select * from blogs join comments on comments.id=blogs.id

If i want to use multiple joins in your query,This function can be called multiple times.

If you need to specify the type of join, you can specify it through the third parameter of this function.The options are:left, right, outer, inner, left outer, and right outer.

$this->db->join ("comments", "comments.id=blogs.id", "left");
//Generate:left join comments on comments.id=blogs.id
php
  • Previous Working with Data in ASPNET 20 Part 68: Adding Additional Columns to the DataTable
  • Next Chapter 54 of Manipulating Data in ASPNET 20: Including a File Upload Option When Adding New Records