Jump to content

#1054 - Unknown column 'xxxx' in 'on clause'


Recommended Posts

Hi,

Get an unknown column error but the code looks fine, wondering if someone else can see anything i'm missing:

 

Table: returns

id (primary)

reference

account_number

 

Table: returns_items

id (primary)

returns_id

qty

gas_type

SELECT *
FROM returns t1
LEFT JOIN returns_items t2 ON t1.id = t2.return_id
WHERE (t1.order_date >= '2013-08-01')

Any help much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/283182-1054-unknown-column-xxxx-in-on-clause/
Share on other sites

programming is an exact science. so far in this thread, your table definition, query, and error message don't match up and due to typos on your part no one here knows which name for the column is correct.

 

you should be copy/pasting actual information if you want someone in a help forum to be able to help you.

Table: returns

---

id (primary)

reference

account_number

order_date

 

Table: returns_items

---

id (primary)

return_id

qty

gas_type

SELECT *
FROM returns t1
LEFT JOIN returns_items t2 ON t1.id = t2.return_id
WHERE (t1.order_date >= '2013-08-01')

Error is:

#1054 - Unknown column 'returns.id' in 'on clause'

SELECT *
FROM returns t1
LEFT JOIN returns_items t2 ON t1.id = t2.return_id
WHERE (t1.order_date >= '2013-08-01')

OR

SELECT *
FROM returns t1
LEFT JOIN returns_items t2 ON returns.id = returns_items.return_id
WHERE (t1.order_date >= '2013-08-01')

Same error only the unknown column 'returns.id' changes.

If I change it to:

SELECT *
FROM returns t1
LEFT JOIN returns_items t2 ON returns_items.return_id = returns.id
WHERE (t1.order_date >= '2013-08-01')

The unknown column becomes 'returns_items.return_id'

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.