• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems creating an SQL query

#1
Hello I'm having problems with an SQL query I'm trying to do with CodeIgniter


Code:
$comments = $this->db
    ->select(array('posts.content', 'posts.id', 'posts.userid', 'posts.postid', 'posts.nodeview', 'posts.questionid','posts.groupid'))->join('users', 'posts.userid = users.id')
    ->select(array('users.username','users.avatarpath'))->order_by('posts.datetimenumber', 'DESC')
    ->limit(20, $page)
    ->get_where('posts', array('posts.userid' => $user['id'],'posts.nodeview !=' => "article",'posts.nodeview !=' => "pm" /*, 'posts.floor >' => 0 */  ) )
    ;


The problem is that I am using 2 NOT queries on posts.nodeview, and only one of them is being applied.

How can I make the query work?
Reply

#2
I can only see one of them: 'posts.nodeview !='

Are you meaning this?
'posts.nodeview ='
Reply

#3
PHP Code:
$this->db
->select('p.content,p.id,p.userid,p.postid,p.nodeview,p.questionid,p.groupid,u.username,u.avatarpath')
->
from('posts p')
->
join('users u''p.userid = u.id')
->
where('p.userid',$user['id'])
->
where_not_in('p.nodeview', array('article','pm'))
->
order_by('p.datetimenumber''DESC')
->
limit(20,$page);
$query $this->db->get();
if (
$query->num_rows() > 0) {
 return 
$query->result();
}
else {
 
  return FALSE;


This will select the records where posts.nodeview is not 'article' and not 'pm'.
Is that what you need?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.