Page 1 of 1

Multiple where

Posted: Wed Mar 16, 2005 11:58 pm
by thesimon
how do you specify 2 where criteria when selecting from mySQL?

Cheers,
Simon

Posted: Thu Mar 17, 2005 12:00 am
by feyd
use the combining operators.. such as OR and AND..


Moved to Databases.

Posted: Thu Mar 17, 2005 4:23 am
by timvw
this is how i usually end up adding a where clause to a query...

Code: Select all

// $this->_where : property
    // $where : optional parameter
    // $q1: the complete query

    if (!empty($this->_where))
    {
      if (!empty($where))
      {
        $where = "($where) AND ($this->_where)";
      }
      else
      {
        $where = $this->_where;
      }
    }
    
    if (!empty($where))
    {
      $q1 .= " WHERE $where";
    }