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.

Data Model Questions /

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

SS3.1 $sqlQuery->addInnerJoin Issue


Go to End


2 Posts   1870 Views

Avatar
SS_Learner

Community Member, 20 Posts

19 April 2013 at 3:09pm

Hi Friends

I am making a query using sqlQuery in Silverstripe 3.1 . Now when i try to add an inner join using
$sqlQuery->addInnerJoin('Member', 'testTable.OwnerID = Member.ID');

the raw query i am getting with this is something like
INNER JOIN "Member" ON testTable.OwnerID = Member.ID,
which when executed in mysql gives syntax error,as there should be no double quotes in the table name,when i remove the quotes,it works.
But how can i resolve this in my code?

Thanks for any kind of help.

Avatar
(deleted)

Community Member, 473 Posts

19 April 2013 at 4:40pm

The generated SQL is correct. SilverStripe runs MySQL in ANSI mode, which means that database, table and column names should be enclosed in double quotes (“) rather than the normal back ticks (`). If you are running the query in a mysql shell, or through something like PHPMyAdmin, you need to run

SET sql_mode=‘ANSI’;
first.