[User Error] Couldn't run query: SELECT DISTINCT MAX("SortOrder") FROM "SiteTree" LEFT JOIN "Page" ON "Page"."ID" = "SiteTree"."ID" LEFT JOIN "Book" ON "Book"."ID" = "SiteTree"."ID" INNER JOIN "HomePage_HomeBooks" ON "HomePage_HomeBooks"."BookID" = "SiteTree"."ID" WHERE ("HomePage_HomeBooks"."HomePageID" = '1') AND ("SiteTree"."ClassName" IN ('Book')) Column 'SortOrder' in field list is ambiguous
GET /admin/pages/edit/show/1
Line 598 in /home/fourcourtspress/public_html/framework/model/MySQLDatabase.php
Source
589 	}
590 
591 	public function databaseError($msg, $errorLevel = E_USER_ERROR) {
592 		// try to extract and format query
593 		if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
594 			$formatter = new SQLFormatter();
595 			$msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
596 		}
597 
598 		user_error($msg, $errorLevel);
599 	}
600 
601 	/**
602 	 * Return a boolean type-formatted string
603 	 *
604 	 * @param array $values Contains a tokenised list of info about this data type
Trace
		Couldn't run query: SELECT DISTINCT MAX("SortOrder") FROM "SiteTree" LEFT JOIN "Page" ON "Page"."ID" = "SiteTree"."ID" LEFT JOIN "Book" ON "Book"."ID" = "SiteTree"."ID" INNER JOIN "HomePage_HomeBooks" ON "HomePage_HomeBooks"."BookID" = "SiteTree"."ID" WHERE ("HomePage_HomeBooks"."HomePageID" = '1') AND ("SiteTree"."ClassName" IN ('Book')) Column 'SortOrder' in field list is ambiguous 
		MySQLDatabase.php:598
		MySQLDatabase->databaseError(Couldn't run query: SELECT DISTINCT MAX("SortOrder") FROM "SiteTree" LEFT JOIN "Page" ON "Page"."ID" = "SiteTree"."ID" LEFT JOIN "Book" ON "Book"."ID" = "SiteTree"."ID" INNER JOIN "HomePage_HomeBooks" ON "HomePage_HomeBooks"."BookID" = "SiteTree"."ID" WHERE ("HomePage_HomeBooks"."HomePageID" = '1') AND ("SiteTree"."ClassName" IN ('Book')) | Column 'SortOrder' in field list is ambiguous,256) 
		MySQLDatabase.php:150
		MySQLDatabase->query(SELECT DISTINCT MAX("SortOrder") FROM "SiteTree" LEFT JOIN "Page" ON "Page"."ID" = "SiteTree"."ID" LEFT JOIN "Book" ON "Book"."ID" = "SiteTree"."ID" INNER JOIN "HomePage_HomeBooks" ON "HomePage_HomeBooks"."BookID" = "SiteTree"."ID" WHERE ("HomePage_HomeBooks"."HomePageID" = '1') AND ("SiteTree"."ClassName" IN ('Book')),256) 
		DB.php:208
		DB::query(SELECT DISTINCT MAX("SortOrder") FROM "SiteTree" LEFT JOIN "Page" ON "Page"."ID" = "SiteTree"."ID" LEFT JOIN "Book" ON "Book"."ID" = "SiteTree"."ID" INNER JOIN "HomePage_HomeBooks" ON "HomePage_HomeBooks"."BookID" = "SiteTree"."ID" WHERE ("HomePage_HomeBooks"."HomePageID" = '1') AND ("SiteTree"."ClassName" IN ('Book')),256) 
		SQLQuery.php:945
		SQLQuery->execute() 
		DataQuery.php:377
		DataQuery->aggregate(MAX("SortOrder")) 
		DataQuery.php:343
		DataQuery->max(SortOrder) 
		DataList.php:711
		DataList->max(SortOrder) 
		GridFieldSortableRows.php:155
		GridFieldSortableRows->fixSortColumn(GridField,ManyManyList) 
		GridFieldSortableRows.php:96
		GridFieldSortableRows->getManipulatedData(GridField,ManyManyList) 
		GridField.php:222
		GridField->getManipulatedList() 
		GridField.php:264
		GridField->FieldHolder() 
		ViewableData.php:363
		ViewableData->obj(FieldHolder,,,1) 
		ViewableData.php:438
		ViewableData->XML_val(FieldHolder,,1) 
		call_user_func_array(Array,Array) 
		SSViewer.php:179
		SSViewer_Scope->__call(XML_val,Array) 
		SSViewer.php:535
		SSViewer_DataPresenter->__call(XML_val,Array) 
		.cache.framework.templates.forms.TabSet.ss:68
		SSViewer_DataPresenter->XML_val(FieldHolder,,1) 
		.cache.framework.templates.forms.TabSet.ss:68
		include(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.framework.templates.forms.TabSet.ss) 
		SSViewer.php:997
		SSViewer->includeGeneratedTemplate(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.framework.templates.forms.TabSet.ss,TabSet,,Array,) 
		SSViewer.php:1064
		SSViewer->process(TabSet,) 
		ViewableData.php:336
		ViewableData->renderWith(Array) 
		TabSet.php:83
		TabSet->FieldHolder() 
		ViewableData.php:363
		ViewableData->obj(FieldHolder,,,1) 
		ViewableData.php:438
		ViewableData->XML_val(FieldHolder,,1) 
		call_user_func_array(Array,Array) 
		SSViewer.php:179
		SSViewer_Scope->__call(XML_val,Array) 
		SSViewer.php:535
		SSViewer_DataPresenter->__call(XML_val,Array) 
		.cache.cms.templates.Includes.CMSMain_EditForm.ss:58
		SSViewer_DataPresenter->XML_val(FieldHolder,,1) 
		.cache.cms.templates.Includes.CMSMain_EditForm.ss:58
		include(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.cms.templates.Includes.CMSMain_EditForm.ss) 
		SSViewer.php:997
		SSViewer->includeGeneratedTemplate(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.cms.templates.Includes.CMSMain_EditForm.ss,CMSForm,,Array,) 
		SSViewer.php:1064
		SSViewer->process(CMSForm,) 
		ViewableData.php:336
		ViewableData->renderWith(Array) 
		Form.php:1334
		Form->forTemplate() 
		ViewableData.php:439
		ViewableData->XML_val(EditForm,,1) 
		call_user_func_array(Array,Array) 
		SSViewer.php:179
		SSViewer_Scope->__call(XML_val,Array) 
		SSViewer.php:535
		SSViewer_DataPresenter->__call(XML_val,Array) 
		.cache.cms.templates.Includes.CMSMain_Content.ss:92
		SSViewer_DataPresenter->XML_val(EditForm,,1) 
		.cache.cms.templates.Includes.CMSMain_Content.ss:92
		include(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.cms.templates.Includes.CMSMain_Content.ss) 
		SSViewer.php:997
		SSViewer->includeGeneratedTemplate(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.cms.templates.Includes.CMSMain_Content.ss,CMSPageEditController,,Array,) 
		SSViewer.php:1064
		SSViewer->process(CMSPageEditController,) 
		ViewableData.php:336
		ViewableData->renderWith(Array) 
		LeftAndMain.php:711
		LeftAndMain->Content() 
		ViewableData.php:363
		ViewableData->obj(Content,,,1) 
		ViewableData.php:438
		ViewableData->XML_val(Content,,1) 
		call_user_func_array(Array,Array) 
		SSViewer.php:179
		SSViewer_Scope->__call(XML_val,Array) 
		SSViewer.php:535
		SSViewer_DataPresenter->__call(XML_val,Array) 
		.cache.framework.admin.templates.LeftAndMain.ss:36
		SSViewer_DataPresenter->XML_val(Content,,1) 
		.cache.framework.admin.templates.LeftAndMain.ss:36
		include(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.framework.admin.templates.LeftAndMain.ss) 
		SSViewer.php:997
		SSViewer->includeGeneratedTemplate(/home/fourcourtspress/public_html/silverstripe-cache/fourcourtspress/.cache.framework.admin.templates.LeftAndMain.ss,CMSPageEditController,,Array,) 
		SSViewer.php:1064
		SSViewer->process(CMSPageEditController,) 
		ViewableData.php:336
		ViewableData->renderWith(SSViewer) 
		LeftAndMain.php:588
		LeftAndMain->{closure}() 
		call_user_func(Closure) 
		PjaxResponseNegotiator.php:82
		PjaxResponseNegotiator->respond(SS_HTTPRequest) 
		LeftAndMain.php:565
		LeftAndMain->show(SS_HTTPRequest) 
		RequestHandler.php:288
		RequestHandler->handleAction(SS_HTTPRequest,show) 
		Controller.php:194
		Controller->handleAction(SS_HTTPRequest,show) 
		RequestHandler.php:200
		RequestHandler->handleRequest(SS_HTTPRequest,DataModel) 
		Controller.php:153
		Controller->handleRequest(SS_HTTPRequest,DataModel) 
		LeftAndMain.php:441
		LeftAndMain->handleRequest(SS_HTTPRequest,DataModel) 
		AdminRootController.php:93
		AdminRootController->handleRequest(SS_HTTPRequest,DataModel) 
		Director.php:366
		Director::handleRequest(SS_HTTPRequest,Session,DataModel) 
		Director.php:152
		Director::direct(/admin/pages/edit/show/1,DataModel) 
		main.php:189