1

i have to do a select from multi tables using zend_db_select for this sql :

SELECT t1.id,t2.ids, t3.uid 
FROM table1 t1,table2 t2, table3 t3

this is the code used :

$subQuery = $this->getDbTable ()->select ()->setIntegrityCheck ( false )
->from(array('t1'=>'table1','t2'=>'table2','t3'=>'table3'),array('t1.id','t2.ids','t3.uid'))
->query()
->fetchAll();

so i have message error say that t2.ids is not in the column list because zend_db_select take just the first table

any solution to resolve this problème ? thaks

3
  • Is there any relation between t1.id, t2.ids and t3.uid? Maybe you could re-write your SQL query based on JOINs. Commented May 14, 2013 at 13:14
  • there is no relations between tables Commented May 14, 2013 at 13:52
  • Well, in that case you can always execute your raw MySQL query. Commented May 14, 2013 at 14:29

1 Answer 1

0

You can use a cross join with:

$subQuery = $this->getDbTable ()->select ()->setIntegrityCheck ( false )
->from(array('t1'=>'table1'),array('t1.id'))
->joinCross(array('t2'=>'table2'),array('t2.ids'))
->joinCross(array('t3'=>'table3'),array('t3.uid'))
->query()
->fetchAll();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.