Mysql subquery difference error -
hey guys new mysql ..i have wrote 2 types of code,
first typeselect id, (select n.name customers n grouping salary ) m customers;
second type select id, (select n.name customers n) m grouping salary;
the first 1 works fine expected sec 1 didnt ..it throws me error like
unknown column 'id' in 'field list': select id (select name customers ) m grouping salary
so question can sec way done in mysql without errors ??
hope guys can help me out..thx
your sec 1 fails because request column id
subquery not have id
:
select id, (select n.name customers n) m grouping salary;
it has name
. need add together both id
, salary
subquery if wish utilize them in main query.
select id, (select n.id, n.salary customers n) m grouping salary;
also @strawyberry pointed out... it's nonsense. grouping field isn't in select clause which... don't know. subquerying on doesn't need subqueried. do:
select m.id, customers m grouping m.salary;
mysql
No comments:
Post a Comment