0
user        user_details

id          id
username    username
email       email
password    firstname
balance     lastname
etc         address
....        etc...

What will be my sql command in Codeigniter if I search all username start with A in both table. I want also all the values from two tables.

4

2 回答 2

0

在 mysql 中:

select u.*, ud.* from users u, user_details ud where u.username like "%A%" and ud.username like "%A%"

在 Codeigniter 中是这样的:

$sql = "select u.*, ud.* from users u, user_details ud where u.username like '%A%' and ud.username like '%A%'"
$this->db->query($sql)
于 2013-05-31T09:08:01.933 回答
0
$this->db->select('*');
$this->db->from('user');
$this->db->from('userdetail');
$this->db->like('username','A','after');
$this->db->get();

试试这个可能对你有帮助

于 2013-05-31T09:09:33.183 回答