Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6799503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:51:22+00:00 2026-05-26T18:51:22+00:00

I want to make this query on Symfony/Propel SELECT folders.NAME, COUNT(documents.NAME), COUNT(files.idfiles), SUM(files.size) FROM

  • 0

I want to make this query on Symfony/Propel

SELECT 
folders.NAME,
COUNT(documents.NAME),
COUNT(files.idfiles),
SUM(files.size)

FROM  `folders`
LEFT JOIN `documents_has_folders` ON (documents_has_folders.folders_idfolders = folders.idfolders)
LEFT JOIN documents ON (documents_has_folders.DOCUMENTS_IDDOCUMENTS=documents.IDDOCUMENTS) 
LEFT JOIN files ON (documents.IDDOCUMENTS=files.DOCUMENTS_IDDOCUMENTS) 

GROUP BY folders.idfolders

I do this query

$x = FoldersQuery::create()
            ->addSelectColumn(FoldersPeer::NAME)
            ->addSelectColumn("COUNT(".DocumentsPeer::IDDOCUMENTS.")")
            ->addSelectColumn("COUNT(".FilesPeer::IDFILES.")")
            ->addSelectColumn("SUM(".FilesPeer::SIZE.")")
            ->addJoin(DocumentsHasFoldersPeer::FOLDERS_IDFOLDERS, FoldersPeer::IDFOLDERS, CRITERIA::LEFT_JOIN)
            ->addJoin(DocumentsHasFoldersPeer::DOCUMENTS_IDDOCUMENTS, DocumentsPeer::IDDOCUMENTS, CRITERIA::LEFT_JOIN)
            ->addJoin(DocumentsPeer::IDDOCUMENTS, FilesPeer::DOCUMENTS_IDDOCUMENTS, CRITERIA::LEFT_JOIN)
            ->addGroupByColumn(FoldersPeer::IDFOLDERS)
            ->find();

This returns:

500 | Internal Server Error | PropelException
Unable to execute SELECT statement [SELECT folders.NAME, COUNT(documents.IDDOCUMENTS), COUNT(files.IDFILES), SUM(files.SIZE) FROM LEFT JOIN folders ON (documents_has_folders.FOLDERS_IDFOLDERS=folders.IDFOLDERS) LEFT JOIN documents ON (documents_has_folders.DOCUMENTS_IDDOCUMENTS=documents.IDDOCUMENTS) LEFT JOIN files ON (documents.IDDOCUMENTS=files.DOCUMENTS_IDDOCUMENTS) WHERE folders.REMOVE_DATE IS NULL GROUP BY folders.IDFOLDERS] [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN folders ON (documents_has_folders.FOLDERS_IDFOLDERS=folders.IDFOLDERS)' at line 1]

Why there is no table on FROM??? Why it creates a wrong query?

Thanks a lot.

EDITED:

Same problem have and if i do the query like this:

$c = new Criteria();
    $c->addSelectColumn(FoldersPeer::NAME);
    $c->addSelectColumn("COUNT(".DocumentsPeer::IDDOCUMENTS.")");
    $c->addSelectColumn("COUNT(".FilesPeer::IDFILES.")");
    $c->addSelectColumn("SUM(".FilesPeer::SIZE.")");

    $c->addJoin(DocumentsHasFoldersPeer::FOLDERS_IDFOLDERS, FoldersPeer::IDFOLDERS, CRITERIA::LEFT_JOIN);
    $c->addJoin(DocumentsHasFoldersPeer::DOCUMENTS_IDDOCUMENTS, DocumentsPeer::IDDOCUMENTS, CRITERIA::LEFT_JOIN);
    $c->addJoin(DocumentsPeer::IDDOCUMENTS, FilesPeer::DOCUMENTS_IDDOCUMENTS, CRITERIA::LEFT_JOIN);

    $c->addGroupByColumn(FoldersPeer::IDFOLDERS);

Again after FROM there is no table…

Unable to execute SELECT statement [SELECT folders.NAME, COUNT(documents.IDDOCUMENTS), COUNT(files.IDFILES), SUM(files.SIZE) FROM LEFT JOIN folders ON (documents_has_folders.FOLDERS_IDFOLDERS=folders.IDFOLDERS AND folders.remove_date IS NULL ) LEFT JOIN documents ON (documents_has_folders.DOCUMENTS_IDDOCUMENTS=documents.IDDOCUMENTS AND documents.remove_date IS NULL ) LEFT JOIN files ON (documents.IDDOCUMENTS=files.DOCUMENTS_IDDOCUMENTS AND documents.remove_date IS NULL AND files.remove_date IS NULL ) WHERE folders.remove_date IS NULL AND documents.remove_date IS NULL AND files.remove_date IS NULL GROUP BY folders.IDFOLDERS] [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN folders ON (documents_has_folders.FOLDERS_IDFOLDERS=folders.IDFOLDERS ' at line 1]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:51:23+00:00Added an answer on May 26, 2026 at 6:51 pm

    This is not the Propel way to build queries since Propel 1.6 (maybe before). We don’t use Criteria nor Peer classes. The following query:

    SELECT 
    folders.NAME,
    COUNT(documents.NAME),
    COUNT(files.idfiles),
    SUM(files.size)
    
    FROM  `folders`
    LEFT JOIN `documents_has_folders` ON (documents_has_folders.folders_idfolders = folders.idfolders)
    LEFT JOIN documents ON (documents_has_folders.DOCUMENTS_IDDOCUMENTS=documents.IDDOCUMENTS) 
    LEFT JOIN files ON (documents.IDDOCUMENTS=files.DOCUMENTS_IDDOCUMENTS) 
    

    Can be written like that:

    $query = FoldersQuery::create())
        ->joinDocuments('documents')
        ->joinFiles('files')
        ->withColumn('COUNT(documents.NAME)', 'CountName')
        ->withColumn('COUNT(files.IDFILES)', 'CountIdFiles')
        ->withColumn('SUM(files.size)', 'Sum')
        ->select(array('Name', 'CountName', 'CountIdFiles', 'Sum'))
        ;
    

    It may requires adjustments but it’s the right way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make this kind of query: create procedure something @name varchar(13) as
Basically I want to make this SQL query with linq: SELECT * FROM Orders
I want to make this sql query in doctrine: SELECT * FROM ( (SELECT
I will make this quick and simple I have a query and I want
Under the my query.I select this way all job count by fullname. SELECT COUNT(sy.FullName)
how can I make this sql query return zero for the count function instead
I want to make a select query with an and condition. dept, divi, comp
please take a look of this query: SELECT DATE(datetime), COUNT(1) as numVisits FROM .table_stats.
I have this query: $query = SELECT ads.*, trafficsource.name AS trafficsource, placement.name AS placement,
I want to make this hierarchy: <ul id=red class=treeview-red> <li><span>Item 1</span> <ul> <li><span>Item 1.0</span>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.