0

My Query:

select distinct ml.send_to from message_log as ml where NOT exists
(select mobile_no from user_details WHERE user_details.mobile_no = ml.send_to);
Gunaseelan
  • 2,494
  • 5
  • 36
  • 43

2 Answers2

1
$select1 = $db->select()->from('user_details',array('mobile_no'))
                  ->where('user_details.mobile_no = ml.send_to');

$select2 = $db->select()->distinct()
               ->from(array('ml'=>'message_log'), array('ml.send_to')))
               ->where('NOT EXISTS ?', $select1);

This will do the trick in the easiest way.

Ignacio Ruiz
  • 611
  • 10
  • 21
0

you can use customer query in zend as

$sql = 'select distinct ml.send_to from message_log as ml where NOT exists
(select mobile_no from user_details WHERE user_details.mobile_no = ml.send_to);';

 $stmt = new Zend_Db_Statement_Mysqli($db, $sql);
 $stmt->execute();
 while ($row = $stmt->fetch()) {
   echo $row['send_to'];
 }

this will really help you

http://framework.zend.com/manual/1.12/en/zend.db.statement.html

Danyal Sandeelo
  • 12,196
  • 10
  • 47
  • 78