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); 
    $query
        ->select(array('type', 'name', 'id', 'created_by', 'amount', 'created', 'cat_id', 'status'))
        ->from($db->quoteName('#__zoo_item'))
        ->where($db->quoteName('created_by') .' = '.$db->quote(10))
        ->where($db->quoteName('status') .' IN '.$db->quote(1,2,4))//THIS IS MY PROBLEM.
        ->group($db->quoteName('created_by'))
        ->order('id DESC')
        ->setLimit(1);
    $db->setQuery($query);
    $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


What's the proper chaining for WHERE

Updated January 29, 2018 18:10 PM

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