|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
rewriting a query with subquery to one without a subquery
hello....i have a bit of a problem. I have the following sql query:
SELECT t1.topicid,t1.forumid,t1.titel,t1.slotje,p1.timest amp FROM topic t1, post p1 WHERE t1.forumid = $forum and p1.forumid = $forum and t1.topicid = p1.topicid and p1.timestamp = ( select max(timestamp) from post where forumid = $forum and topicid = p1.topicid) order by p1.timestamp desc the problem is the mysql server i use doesnt support subqueries. Can anyone help me find a different sql query that does the same without a subquery? |
|
#2
|
|||
|
|||
|
RE: rewriting a query with subquery to one without a subquery
There really isn't a way you can do it with one query, to my knowledge.
http://www.mysql.com/documentation/...olumn-group-row The link above might give you some insight as to the most efficient way to handle this situation. |
|
#3
|
|||
|
|||
|
RE: rewriting a query with subquery to one without a subquery
If your server does not support subquries, you should do it in two queries.
Generaly if you are looking just for one value, use variable to hold it. If you are looking for more max values (for example from every forum), use array (or something like that) to hold them. And if you want to do it only in database, just use temporary tables. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > rewriting a query with subquery to one without a subquery |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|