Welcome Guest, Not a member yet? Register   Sign In
Problem with database query
#5

(This post was last modified: 09-22-2017, 06:46 AM by Wouter60.)

There's a fundamental flaw in your join statements.
Join will ask you for the field in table 1 that corresponds with the field in table 2.
If you just want to join records that have the value "accept" in the field votes.content, simply use a where statement.
E.g.:

PHP Code:
$this->db
->select('p.content, p.id, p.userid, v.userid, v.content')
->
from('posts p')
->
join('users u','p.userid = u.id')
->
join('votes v','v.postid = p.id')
->
where('v.questionid'$debate['id'])
->
where('v.content','accept')
->
where('p.floor',0);
$query $this->db->get();
echo 
$this->db->last_query();
$records $query->result_array(); 
Reply


Messages In This Thread
Problem with database query - by desbest - 09-21-2017, 10:57 AM
RE: Problem with database query - by rtenny - 09-22-2017, 03:34 AM
RE: Problem with database query - by InsiteFX - 09-22-2017, 04:11 AM
RE: Problem with database query - by desbest - 09-22-2017, 04:13 AM
RE: Problem with database query - by Wouter60 - 09-22-2017, 05:54 AM
RE: Problem with database query - by desbest - 09-22-2017, 06:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB