How to Use IN Clause in Joomla Query

by David Addoteye   Last Updated April 04, 2018 19:10 PM

I am trying to select records where a column is in a suggested list if values using the IN clause. I have tried the query below but the system is not working.

    $db = JFactory::getDbo();
    $query = $db->getQuery(true); 
        ->select(array('type', 'name', 'id', 'created_by', 'amount', 'created', 'cat_id', 'status'))
        ->where($db->quoteName('created_by') .' = '.$db->quote(10))
        ->where($db->quoteName('status') .' IN '.$db->quote(1,2,4))//THIS IS MY PROBLEM.
        ->order('id DESC')
    $loan = $db->loadObject();

The problematic clause is this

->where($db->quoteName('status') .' IN '.$db->quote(1,2,4))

I will be glad if someone can help, thank you.

Tags : mysql joomla-api

Related Questions

Database query outputting twice

Updated February 03, 2019 02:10 AM

Display a Value from a Specific DB Field

Updated April 30, 2016 08:04 AM

Delete users from Joomla V2.5

Updated November 08, 2016 08:04 AM