I have completed my database operation using simple query in Drupal 7.But i want some pagination functionality using Drupal 7 theme_table and there for i have to use Drupal 7 db_select,But i m unable to do so.

please Help me out ASAP,Below Is the mysql Query which i want to convert in db_select:-

SELECT r.ROName, CONCAT(CONCAT(CONCAT(r.Address1, ' - ' , r.Pincode),' - ',d.Distname),' - ',s.StateName) as Address1,r.Phone1, r.Phone2, r.Fax, r.Phone3, r.Pincode, r.DistID,d.Distname, d.DistID, s.StateID, r.StateID, s.StateName FROM ROMaster r JOIN DistrictMaster d ON r.DistID = d.DistID JOIN StateMaster s ON r.StateID = s.StateID WHERE SBUID =1 ORDER BY r.ROName


Why not just use db_query() and pass it sql statement.

i want to use


using the drupal theme table,so i have to use Drupal db_select to use drupal_theme table

Mohammed Charolia
Web Developer

Try this
$query = db_select('ROMaster', 'r');
$query->join('DistrictMaster', 'd', 'r.DistID = d.DistID');
$query->join('StateMaster', 's', 'r.StateID = s.StateID');
$result = $query->fields('r', array('ROName','Address1','Pincode','Phone1','Phone2','Fax','Phone3','DistID','StateID'))
->fields('s', array('StateName','StateID'))
->fields('d', array('Distname','DistID'))
->condition('SBUID', 1, '=')
->orderBy('ROName', 'DESC')

Ajaykumar Gudivada