Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2008, 11:01 AM
Junior Member
 
Join Date: May 2008
Posts: 1
Default select inside select?

I have a Zend_Db_Table class and im trying to run this query:

SELECT * FROM (SELECT * FROM `stories` WHERE submit_date > 1211351819 AND timestamp < 1211438219 ORDER BY diggs DESC) a GROUP BY story_id ORDERY BY diggs DSEC

how would I do it using the select method? I.E. $this->fetchAll($this->select()->....)

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-23-2008, 11:49 AM
Junior Member
 
Join Date: Apr 2008
Posts: 28
Default

I'm no expert on SQL. But that SQL statement seems to be wrong. Have you tried running that SQL line in your database and see if you get a result? It looks wrong to me in syntax at first sight :s.

though your sql would be something like this. (Code is ran inside the model of a certain table)

Code:
$sql = $this->select()->from()->where()->order()->limitpage();

return $this->fetchAll($sql);
Where you fill in the clausules where necessary

e.g.

$sql = $this->select()->where('ID > ?', 3);

will return something like

SELECT * FROM <tablemodel you're in> WHERE (ID = 3)

Last edited by Filip : 05-23-2008 at 11:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:00 PM.