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

(This post was last modified: 09-22-2017, 04:44 AM by desbest.)

Hello I now have a new problem.

Here is my code.

PHP Code:
$acceptal $this->db->select(array('posts.content''posts.id''posts.userid''votes.userid''votes.content'))
->
join('users''posts.userid = users.id')
->
join('votes'"votes.questionid = $debate[id]""votes.content = 'accept'")
->
select(array('users.username','users.avatarpath')
)->
get_where('posts', array('posts.questionid' => $debate['id'], 'posts.floor' => 0)); 

Here is the SQL it generates.


Code:
SELECT `posts`.`content`, `posts`.`id`, `posts`.`userid`, `votes`.`userid`, `votes`.`content`, `users`.`username`, `users`.`avatarpath`
FROM `posts`
JOIN `users` ON `posts`.`userid` = `users`.`id`
JOIN `votes` ON `votes`.`questionid` = 3 WHERE `posts`.`questionid` = '3' AND `posts`.`floor` =0

If you notice, you'll notice that it is not joined to votes.content = "accept".

How do I do this?

I want to join to another table using 2 criteria, not just 1 criteria (the code is only joining to the table with 1 criteria).
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