Plugin

Archived
Forum
(read-only)


For official support, visit the official support site »

Active Record

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From Rob Sanchez

     

Where !=

General

bsrweb
bsrweb

Hi, I must be missing something very obvious to everyone else but I can’t figure out how to correctly display results in a column if it’s not blank. My query:

{exp:activerecord
                select         =  “m_field_id_2”
                from         =  “member_data”
                sort         =  “asc”
                distinct     =  “yes”
                where:m_field_id_2 != ” “
                limit         =  “10”
              }
             
              {count}: {m_field_id_2}

          {/exp:activerecord}

CI Activerecord uses “!=” for NOT in the WHERE clause but this doesn’t seem to work. What am I doing wrong?

Rob Sanchez
# 1
Developer
Rob Sanchez

This syntax won’t work because of the way EE parses out tag parameters. I’ll need to think of an alternate syntax for this scenario.

bsrweb
# 2
bsrweb

Thanks for your response! I’ll use good ole exp:query for this situation then.

Rob Sanchez
# 3
Developer
Rob Sanchez

You could write out the where statement yourself:

{exp:activerecord
                select         
=  “m_field_id_2”
                from         
=  “member_data”
                sort         
=  “asc”
                distinct     
=  “yes”
                where     
”mfield_id_2 != ''“
                limit         
=  “10”
              }
              
              {count}
{m_field_id_2}
          {
/exp:activerecord} 
Rob Sanchez
# 4
Developer
Rob Sanchez

FYI, there’s now support for != and other alternate comparison operators in where statements

where:field[!=]="something"