This topic is locked

Order Asc-Desc with master-detail relationship

8/25/2009 6:03:02 AM
PHPRunner General questions
M
mauro author

i use master-detail relationship between two tables, it's possible order results like this :

https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=12594&image=1&table=forumtopics/ ?

J
Jane 8/25/2009

Hi,
I'm not sure that I understand your question. What values do you want to sort?

M
mauro author 8/25/2009

valus in column 'Lavorazioni' (columun master-detail relationship)

J
Jane 8/25/2009

Could you clarify a bit more?

There are no any values in this column, only links to the detail table.

M
mauro author 8/25/2009

yes, there is no value because this column is the result of master-detail relationship between two tables, phprunner don't create any column, so it's possible create a value to order this column....??

J
Jane 8/26/2009

I'm not sure that I understand this question.

Do you want to create some random values and then use these values to sort records?

J
Jane 8/27/2009

Hi,
unfortunately there is no easy way to add sort link for this column.

As workaround you can sort records in your main SQL query on the Edit SQL query tab.

Here is a sample:

SELECT

Field1,

Field2

(SELECT count(*) FROM

(SELECT OrderID FROM `detail_table` ) `subQuery_cnt`

WHERE `subQuery_cnt`.`KeyField1`=`orders`.`KeyField1`) AS detail_table_cnt2

FROM master_table

ORDER BY detail_table_cnt2 DESC
M
mauro author 8/28/2009

Tnx <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=43719&image=1&table=forumreplies' class='bbc_emoticon' alt=':lol:' />

i used
List page: before Sql query
function BeforeQueryList(&$strSQL,&$strWhereClause,&$strOrderBy)

{
$strOrderBy = ("order by detail_table_cnt2 DESC");

}