Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

LEFT JOIN Problem


Go to End


2 Posts   2186 Views

Avatar
thejackel

Community Member, 33 Posts

29 May 2008 at 10:43pm

Edited: 29/05/2008 10:43pm

Hello,

I'm trying to implement a custom search and am linking two tables together using LEFT JOIN. Below is the query I am running:

$links = DataObject::get("SiteTree", "ShowInMenus = 1 AND ParentID = 23", "", "LEFT JOIN ConsultationPaperHolder ON ConsultationPaperHolder.ID = SiteTree.ID", "0, 10");

It's supposed to join my ConsultationPaperHolder to the SiteTree table using ID. The problem is it keeps bringing back an Error page. It works withou the JOIN but just can't get it working with it.

anybody have any ideas whats wrong with this?

Thanks

Avatar
thejackel

Community Member, 33 Posts

29 May 2008 at 10:55pm

Resolved it. SiteTree.ID needed to be `SiteTree`.ID

Hopefully this may help someone in future :)