Reputation: 1
I am trying to run this query:
SELECT DISTINCT col1
FROM
(
SELECT CONCAT(retailerId,'_recharge') FROM retailerinformation
WHERE Channel='videocon' AND retailerId='kioskpb20130909045617'
)
but every time on running I get this error:
Error Code : 1248 Every derived table must have its own alias
Upvotes: 0
Views: 97
Reputation: 1
In addition to adding the alias on the subquery, columns called on the outer query should exist in the sub query. In this case, col1 should exist in the sub query. With that said, this should work
SELECT DISTINCT col1
FROM
(
SELECT CONCAT(retailerId,'_recharge') col1 FROM retailerinformation
WHERE Channel='videocon' AND retailerId='kioskpb20130909045617'
) sub
Upvotes: 0
Reputation: 1
This will work:
SELECT
DISTINCT col1
FROM (
SELECT concat(retailerId,'_recharge')
FROM retailerinformation where Channel='videocon' and retailerId='kioskpb20130909045617'
) AS alias
Upvotes: 0
Reputation:
Try this version:
select DISTINCT col1 from
(select concat(retailerId,'_recharge') from retailerinformation
where Channel='videocon' and retailerId='kioskpb20130909045617') as retailerino
Note the alias on your subquery.
Upvotes: 0
Reputation: 37365
Your error is very clear. Create an alias:
SELECT DISTINCT
col1
FROM
(select concat(retailerId,'_recharge') from retailerinformation where Channel='videocon' and retailerId='kioskpb20130909045617') AS tmp_table
hint: if you'll try to understand errors, not just read them - this will be success story.
Upvotes: 3