3
SELECT m.id, m.title, m.message, m.from, m.to2, m.to_viewed, m.from_viewed, m.created, u.username 
FROM tbl_messages m 
INNER JOIN tbl_users u 
ON m.from = u.id WHERE m.to2 = '1' && m.to_saved = '1'  && m.to_deleted = '0' 
ORDER BY m.created DESC

Having removed m.from, the query runs. It doesn't like this field name. Is 'from' reserved? Could someone suggest a fix?

Thanks

2

5 Answers 5

3

Yes, it's one of the reserved words. Use backticks to quote it:

m.`from`
Sign up to request clarification or add additional context in comments.

Comments

3

Wrap it with backticks, because it is mysql's reserved keyword

m.`from`

Here is a full list of reserved words

Comments

1

From is reserved, yes. You could try adding quotes around it. The easiest is to avoid using reserved words in queries.

Comments

1

Yes it is a reserved word. You should enclose from in back ticks like

m.`from`

Comments

0

Yes, "from" is reserved. In mysql, IIRC you can put it in either double quotes (") or backquotes (`) (but I also use postgresql, so I may be confusing the two systems).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.