Pregunta

How to make this work in Zend...

   select name, comment_id, text, date, number
from user, comment, telephone
where user.user_id = comment.user_id
and telephone.telephone_id = comment.telephone_id
and telephone.number = 000;

Thank you

¿Fue útil?

Solución

I'm not sure about which column belongs to which table but it is quite simple to change it if I made a mistake. The query in Zend could be written like this :

$select = $db->select();
$select->from('user', array('name'));
$select->join('comment', 'user.user_id = comment.user_id', array('comment_id', 'text', 'date'));
$select->join('telephone', 'telephone.telephone_id = comment.telephone_id', array('number'));
$select->where('telephone.number = ?', '000');

I suggest you to read the documentation to be able to build select queries easily.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top