Good afternoon!
According to my law, all empty cells in the MySQL database should be NULL, but I have a SQL query that involves searching users by 4 criteria, first name, last name, city, gender. But a problem arises, if a user has at least one of these NULL cells, then it does not fall under LIKE and, accordingly, under the result, how can I solve this?
$users = Users::findByRawSql('u.f_name LIKE ? AND u.s_name LIKE ? AND u.sex LIKE ? AND u.city LIKE ?', array( $this->_addLike($this->request->getPost('f_name')), $this->_addLike($this->request->getPost('s_name')), $this->_addLike($this->request->getPost('sex')), $this->_addLike($this->request->getPost('city')) )); $sql = "SELECT u.id, u.avatar, u.city, u.f_name, u.s_name, u.notes, u.username, SUM(b.summ) AS summ FROM users AS u LEFT JOIN balance AS b ON b.user_id = u.id WHERE $conditions GROUP BY u.id ORDER BY summ DESC";
.... field LIKE '%%'
- zb '10