我无法使用联接表提取结果

时间:2019-06-16 09:48:42

标签: php sql join

我有2张桌子

它拥有的第一台演员

 ID      name_english           picture               link
 5       Daniela Bessia         4f8ab755ed.png        daniela-bessia
 6       Mohannad Alarjan       14f8dfsf55ed.png      mohannad-alarjan
 7       Lee Tae-Im             kxe3gj64.jpg          lee-tae-im

第二个表actors_content

id       content_id      actors_id
1        7               5
2        5               5
3        5               6
4        5               7

现在我的查询是按戏剧ID请求的,如果访问者访问的戏剧ID为7(content_id),则应该在第二个表actors_content上进行搜索,并选择所有要成为content_id = 7的数据,我希望一一加入而对于没有重复数据的演员数据,可以从演员那里获取演员详细信息

public function dodisplayActorsbycontent($getid){
$query = $this->db->query("SELECT `actors`.`id` , `actors`.`name_english` , `actors`.`picture` , `actors`.`link` , `actors_content`.* FROM `actors_content`, `actors` WHERE `actors_content`.`content_id` = '".$getid."'");
$total = $this->db->resultcount($query);
if($total != 0){
while($this->db->fetchrow($query)){
$list[] = $this->db->_record;
}
return($list);
}else{
return(false);
}
}

1 个答案:

答案 0 :(得分:-1)

联接需要一个function testPostgres(){ const moment = require('moment-timezone') const Client = require('pg-native') const client = new Client() client.connect('postgres://postgres:postgres@host:5432/postgres', function(err) { if(err) throw err const moment1 = moment() for (let i = 0; i < 1000; i++) { let rows = client.querySync('update json_test set data = data || \'{"SkillChance": 1}\', count =count+1 where id =$1',[1]) } const moment2 = moment() const diff = moment2.diff(moment1, 'seconds') console.log(diff) // }) } 子句,而您错过了它:

ON