MySQL Forums
Forum List  »  Newbie

Confused as to why this sql statement is not working
Posted by: Terry R
Date: February 01, 2019 07:41PM

Having trouble with what I thought would be a simple sql query (note: I don't have any control over the data schema or data) ... basically 2 related tables where both need to match external parameters and have a relationship that is a concatenation of a constant and the other's main id

External params
aid = 123
bid = 456

select
B.data,
('x-' + B.id) as CID,
A.bid,
A.aSort
from A
inner join B on A.xid = CID
where a.id = aid and b.id = bid
order by A.aSort

phpMyAdmin is complaining that CID is undefined in line 7?

If I replace ('x-' + B.id) as CID, with B.id, and change the join to mid(A.xid,3,9) = B.id this query works

Just not understanding why my original query doesn't work?

Options: ReplyQuote


Subject
Written By
Posted
Confused as to why this sql statement is not working
February 01, 2019 07:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.