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 7525039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:13:42+00:00 2026-05-30T03:13:42+00:00

I have been trying to get this query to work but I am stumbed

  • 0

I have been trying to get this query to work but I am stumbed right now.
Problem is on the JOIN with GROUP_CONCAT in it. I just can’t figure how to get it working.

What I want is to get buntch of data from RFQs and joining Customers, etc. to it and everything was fine until I had to change Suppliers field so that it could have multiple suplliers per one RFQs row. I created new tables RFQsSuppliers where I combine Supplier.ID’s and RFQs.ID’s and I have table Suppliers that contains the names and other stuff.

I want to get Suppliers to have all suppliers separated with ‘,’.

My Query:

$result = mysql_query("SELECT     Pullero.DateAdded as DateAdded,
                              Customers.Name as customer,
                              Pullero.ID as RFQID,
                              Ships.Name as ship,
                              Pullero.CustomerRef as CustomerRef,
                              Contacts.FirstName as contactF,
                              Contacts.LastName as contactL,
                              Contacts.Email as contactE,
                              Users.tunnus as handler,
                              RFQStatus.Name as status,
                              Pullero.Description as RFQDescription,
                              Pullero.LastEdited as LastEdit
                   FROM       RFQs Pullero
                   JOIN      (SELECT    RFQs.ID,
                                        GROUP_CONCAT(Supplier.Name) AS Suppliers
                              FROM      RFQs 
                              LEFT JOIN RFQsSuppliers ON RFQs.ID = RFQsSuppliers.RFQID
                              JOIN      Suppliers ON RFQsSuppliers.SupplierID = Suppliers.ID
                              GROUP BY  RFQs.ID) 
                              RFQsSuppliers ON Pullero.ID = RFQsSuppliers.RFQID

                   LEFT JOIN  Ships ON RFQ.ShipID=Ships.ID
                   LEFT JOIN  Contacts ON RFQ.ContactID=Contacts.ID
                   LEFT JOIN  Customers ON RFQ.CustomerID=Customers.idCustomers
                   LEFT JOIN  Users ON RFQ.PriJobHandler=Users.id
                   LEFT JOIN  RFQStatus ON RFQ.StatusID=RFQStatus.ID
                   WHERE      RFQs.LastEdited > '$lastedited'
                   ORDER BY   RFQs.LastEdited ASC
                  ") or die(mysql_error());

At the moment, error is :Unknown column ‘Supplier.Name’ in ‘field list’

EDIT

Below is some expample of my Table desing:

  RFQs
  ID | DateAdded | CustomerID | ShipID | LastEdited | StatusID ...

  /* -------------------------------------- */
  Suppliers
  ID | Name | CountryID
  1    Sup1   2
  2    Sup2   5
  3    Sup3   3
  4    Sup4   3
  /* -------------------------------------- */
  RFQsSuppliers
  ID | RFQID | SupplierID
  1    1       4
  2    2       3
  3    56      3
  4    4       3
  5    39      1
  6    56      1
  7    4       4

I tried to get only the suppliers with following query:

$result = mysql_query("SELECT     Suppliers.Name as Suppliers
                   FROM       RFQs
                   LEFT JOIN  RFQsSuppliers ON RFQs.ID=RFQsSuppliers.SupplierID
                   LEFT JOIN  Suppliers ON RFQsSuppliers.SupplierID=Suppliers.ID
                   GROUP BY   RFQs.ID
                  ") or die(mysql_error());

But print_r on each row returns only following:

Array ( [Suppliers] => Sup1,Sup1 ) Array ( [Suppliers] => ) Array ( [Suppliers] => Sup4,Sup4 ) Array ( [Suppliers] => ) Array ( [Suppliers] => ) Array ( [Suppliers] => )

Any ideas?

  • 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-30T03:13:43+00:00Added an answer on May 30, 2026 at 3:13 am
    JOIN      (
        SELECT    RFQs.ID,
                  GROUP_CONCAT(Supplier**s**.Name) AS Suppliers
        FROM      RFQs 
        LEFT JOIN RFQsSuppliers ON RFQs.ID = RFQsSuppliers.RFQID
        JOIN      Suppliers ON RFQsSuppliers.SupplierID = Suppliers.ID
        GROUP BY  RFQs.ID
    ) RFQsSuppliers
    

    Try that

    I believe you missed an ‘s’ in your GROUP_CONCAT table name as you had it as Supplier.Name instead of Suppliers.name as per the table

    Edit

    Additionally you are referring to RFQs.LastEdited in WHERE and ORDER BY clauses however you aliased table RFQs to be named Pullero, so those will need changing to Pullero.LastEdited

    Edited edit Reformatted to use JOINs instead of SUBQUERY

    SELECT     
        Pullero.DateAdded as DateAdded,
        Customers.Name as customer,
        Pullero.ID as RFQID,
        GROUP_CONCAT(Suppliers.Name) AS Suppliers,
        Ships.Name as ship,
        Pullero.CustomerRef as CustomerRef,
        Contacts.FirstName as contactF,
        Contacts.LastName as contactL,
        Contacts.Email as contactE,
        Users.tunnus as handler,
        RFQStatus.Name as status,
        Pullero.Description as RFQDescription,
        Pullero.LastEdited as LastEdit
    
    FROM       RFQs AS Pullero
    LEFT JOIN  RFQsSuppliers ON RFQsSuppliers.RFQID = Pullero.ID
    LEFT JOIN  Suppliers ON RFQSuppliers.SupplierID = Suppliers.ID
    LEFT JOIN  Ships ON RFQ.ShipID=Ships.ID
    LEFT JOIN  Contacts ON RFQ.ContactID=Contacts.ID
    LEFT JOIN  Customers ON RFQ.CustomerID=Customers.idCustomers
    LEFT JOIN  Users ON RFQ.PriJobHandler=Users.id
    LEFT JOIN  RFQStatus ON RFQ.StatusID=RFQStatus.ID
    WHERE      Pullero.LastEdited > '$lastedited'
    ORDER BY   Pullero.LastEdited ASC
    

    Or for an example using original subquery, the RFQs link seems superfulous so I’ve adjusted it + have added the Suppliers list into the output

    $result = mysql_query("SELECT     Pullero.DateAdded as DateAdded,
                                  RFQsSuppliers.Suppliers,
                                  Customers.Name as customer,
                                  Pullero.ID as RFQID,
                                  Ships.Name as ship,
                                  Pullero.CustomerRef as CustomerRef,
                                  Contacts.FirstName as contactF,
                                  Contacts.LastName as contactL,
                                  Contacts.Email as contactE,
                                  Users.tunnus as handler,
                                  RFQStatus.Name as status,
                                  Pullero.Description as RFQDescription,
                                  Pullero.LastEdited as LastEdit
                       FROM       RFQs Pullero
                       JOIN      (
                          SELECT    RFQsSuppliers.RFQID,
                                    GROUP_CONCAT(Suppliers.Name) AS Suppliers
                          FROM      RFQsSuppliers.RFQID
                          JOIN      Suppliers ON RFQsSuppliers.SupplierID = Suppliers.ID
                          GROUP BY  RFQsSuppliers.RFQID
                        ) AS RFQsSuppliers ON Pullero.ID = RFQsSuppliers.RFQID
                       LEFT JOIN  Ships ON RFQ.ShipID=Ships.ID
                       LEFT JOIN  Contacts ON RFQ.ContactID=Contacts.ID
                       LEFT JOIN  Customers ON RFQ.CustomerID=Customers.idCustomers
                       LEFT JOIN  Users ON RFQ.PriJobHandler=Users.id
                       LEFT JOIN  RFQStatus ON RFQ.StatusID=RFQStatus.ID
                       WHERE      Pullero.LastEdited > '$lastedited'
                       ORDER BY   Pullero.LastEdited ASC
                      ") or die(mysql_error());
    

    EDIT Updated query for second part of question

    $result = mysql_query("SELECT RFQs.ID, GROUP_CONCAT(Suppliers.Name) as Suppliers
                       FROM       RFQs
                       LEFT JOIN  RFQsSuppliers ON RFQs.ID=RFQsSuppliers.RFQID
                       LEFT JOIN  Suppliers ON RFQsSuppliers.SupplierID=Suppliers.ID
                       GROUP BY   RFQs.ID
                      ") or die(mysql_error());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to get this working for quite a while now but
I've been trying to get this complex MYSQL query to work exactly right over
I have been trying to get this query to work for the longest and
I have been trying to get this to work correctly and I think I
I have been trying to get this jsfiddle to work. So far without luck.
I have been trying to days now to get this website completed ... however,
This is crazy, I have been trying for hours to get this to work.
I've been trying all sorts to get this to work, I have a table
I've been stuck for quite a while now trying to get this query to
I have been trying to get this to work for most of the day

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.