我有一个以 id
作为主键的 users
表和一个以 id
作为主键的 leads
表外键。我想通过 users
的 id
以及来自 leads
的 id
显示用户表中的信息> 表:
public function query($sql, $params = array()) {
$this->_error = false;
if($this->_query = $this->_pdo->prepare($sql)) {
$x = 1;
if(count($params)) {
foreach($params as $param) {
$this->_query->bindValue($x, $param);
$x++;
}
}
if($this->_query->execute()) {
$this->_results = $this->_query->fetchAll(PDO::FETCH_OBJ);
$this->_count = $this->_query->rowCount();
} else {
$this->_error = true;
}
}
return $this;
}
public function get($table, $where) {
return $this->action('SELECT *', $table, $where);
}
最佳答案
你编码了吗?您需要使用联接。
Select u.id , l.id from users u, leads l where u.id = l.user_id
或
所有数据 frm 用户和仅 ID frm 潜在客户
Select u.* , l.id from users u, leads l where u.id = l.user_id
假设 user_id 是销售线索表中的列名
关于php - 显示用户表和潜在客户表中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19928240/