troubleshooting Question

Unknown column in field list

Avatar of BenthamLtd
BenthamLtd asked on
DatabasesPHPSQL
10 Comments1 Solution828 ViewsLast Modified:
Yet again, this is probably something easy that I've completely overlooked so here it is.

In a nutshell, this is an extract of a search query on my system. Works brilliantly, apart from one of the joins/selects. Every time I run it, always returns "Unknown column 'dd_gar_how_returned.GARHowReturned' in 'field list' ".

Here is the query extract in full:

SELECT
        sheets.Sheet_No AS Sheet_No,
        sheets.Sales_Ledger_No AS Sales_Ledger_No,
        sheets.CreationDateTime AS CreationDateTime,
        sheets.LatestModification AS LatestModification,
        sheets.LoggedBy AS LoggedBy,
        sheets.CompanyName AS CompanyName,
        sheets.ContactName AS ContactName,
        sheets.Postcode AS Postcode,
        sheets.Email AS Email,
        sheets.Phone AS Phone,
        sheets.InvoiceDate AS InvoiceDate,  
        goods_actually_returned.GoodsActuallyReturned AS GoodsActuallyReturned,
        goods_actually_returned.GoodsActuallyReturned_qty AS GoodsToBeSentOnReceipt_qty,
        dd_gar_quality.GARQuality AS GoodsActuallyReturned_quality,
        dd_gar_type.GARType AS GoodsActuallyReturned_type,
        dd_gar_supplier.GARSupplier AS GoodsActuallyReturned_supplier,
        dd_gar_how_returned.GARHowReturned AS HowReturned,
        consignment_no.ConsignmentNo AS ConsignmentNo

FROM sheets

LEFT JOIN goods_actually_returned ON sheets.Sheet_No = goods_actually_returned.Sheet_No

LEFT JOIN dd_gar_quality ON goods_actually_returned.GoodsActuallyReturned_quality = dd_gar_quality.GARQualityID

LEFT JOIN dd_gar_type ON goods_actually_returned.GoodsActuallyReturned_type = dd_gar_type.GARTypeID

LEFT JOIN dd_gar_supplier ON goods_actually_returned.GoodsActuallyReturned_supplier = dd_gar_supplier.GARSupplierID

LEFT JOIN dd_gar_how_returned ON dd_gar_how_returned.GARHowReturnedID = how_returned.HowReturned

LEFT JOIN consignment_no ON sheets.Sheet_No = consignment_no.Sheet_No 

WHERE 

sheets.Sheet_No = goods_actually_returned.Sheet_No 

AND dd_gar_how_returned.GARHowReturned LIKE 'Post (Royal Mail)';


Here is explain on the ref tables for 'dd_gar_how_returned' and 'how_returned':

/* how_returned */
+-------------+---------+------+-----+---------+-------+
| Field       | Type    | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+-------+
| Sheet_No    | int(11) | NO   |     | NULL    |       | 
| HowReturned | int(11) | YES  |     | NULL    |       | 
+-------------+---------+------+-----+---------+-------+

Example data - 
Sheet_No: 11123, HowReturned: 1
Sheet_No 11124, HowReturned: 2

/* dd_gar_how_returned */
+------------------+-------------+------+-----+---------+----------------+
| Field            | Type        | Null | Key | Default | Extra          |
+------------------+-------------+------+-----+---------+----------------+
| GARHowReturnedID | int(11)     | NO   | PRI | NULL    | auto_increment | 
| GARHowReturned   | varchar(50) | YES  |     | NULL    |                | 
+------------------+-------------+------+-----+---------+----------------+

Example data - 
GARHowReturnedID: 1, GARHowReturned: Post (Royal Mail)
GARHowReturnedID: 2, GARHowReturned: Courier

Any ideas, peeps?

Many thanks as always
ASKER CERTIFIED SOLUTION
BenthamLtd

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros