Jump to content


Retrieving from database with multiple id's

where statement select multiple

  • Please log in to reply
4 replies to this topic

#1 iblux

iblux

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 23 May 2012 - 01:43 PM

Hi everyone, I want to use grocery crud to retrieve groups from a database, using their id's, with a query like this:


SELECT * FROM Groups WHERE GroupID IN (3,8,12,23) //etc.


It's quite easy to do when you have a single id with
$crud->where
, but how should I tackle this one with multiple id's?

(btw, thank you web-johnny, for creating such an amazingly simple, and yet extensive crud, keep up the good work! :))

#2 iblux

iblux

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 24 May 2012 - 08:55 AM

Nobody?

#3 kenvogt

kenvogt

    Advanced Member

  • Members
  • PipPipPip
  • 51 posts

Posted 24 May 2012 - 06:33 PM

Try or_where

#4 iblux

iblux

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 25 May 2012 - 10:31 AM

Thanks! I used a foreach loop:

foreach($data['ids'] as $id)
{
       $crud->or_where('grpId', $id);
}


#5 mavershim

mavershim

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 01 October 2012 - 08:47 AM

or you can try
$crud->where("GroupID in (1,2,3,5)");






Also tagged with one or more of these keywords: where, statement, select, multiple

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users