Thread: Referencing named attribute in where clause doesn't work with 7.1.2?
Referencing named attribute in where clause doesn't work with 7.1.2?
From
Andreas Joseph Krogh
Date:
Hi, this is my first post to this list so please... I have problems getting this query to work, any ideas? select article.title_text_key, (select on_text.text_value from on_text whereon_text.text_key = title_text_keyAND NOT title_text_key is NULLAND on_text.lang_id= (select code.id from code, code_group where code.code_group_id = code_group.id AND code_group.description= 'lang' AND code.code_key = 'lang.NO' )) as title_text_value from article where NOT title_text_value is NULL; ERROR: Attribute 'title_text_value' not found Issuing the same query without the where-clause does work tho, but return tupples with null in them which I don't want. -- Andreas Joseph Krogh <andreak@officenet.no>
On Wed, 8 Aug 2001, Andreas Joseph Krogh wrote: > Hi, this is my first post to this list so please... > I have problems getting this query to work, any ideas? > > select article.title_text_key, > (select on_text.text_value from on_text where > on_text.text_key = title_text_key > AND NOT title_text_key is NULL > AND on_text.lang_id = (select code.id from code, code_group where > code.code_group_id = code_group.id > AND code_group.description = 'lang' AND code.code_key = 'lang.NO' > ) > ) > as title_text_value from article where NOT title_text_value is NULL; > > ERROR: Attribute 'title_text_value' not found Hallo Andreas, Relocating your AS clause to the topmost string? BTW, table aliasing would make for less typing. Best of luck! > Issuing the same query without the where-clause does work tho, but > return tupples with null in them which I don't want. > > -- > Andreas Joseph Krogh <andreak@officenet.no> > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -------------------------------------------------------------------- SVCMC - Center for Behavioral Health -------------------------------------------------------------------- Thomas Good tomg@ { admin | q8 } .nrnet.org Programmer/Analyst Phone: 718-354-5528 Residential Services Mobile: 917-282-7359 -------------------------------------------------------------------- /* Die Wahrheit Ist Irgendwo Da Draussen... */ --------------------------------------------------------------------
Re: Referencing named attribute in where clause doesn't workwith 7.1.2?
From
Andreas Joseph Krogh
Date:
Thomas Good wrote: > > On Wed, 8 Aug 2001, Andreas Joseph Krogh wrote: > > > Hi, this is my first post to this list so please... > > I have problems getting this query to work, any ideas? > > > > select article.title_text_key, > > (select on_text.text_value from on_text where > > on_text.text_key = title_text_key > > AND NOT title_text_key is NULL > > AND on_text.lang_id = (select code.id from code, code_group where > > code.code_group_id = code_group.id > > AND code_group.description = 'lang' AND code.code_key = 'lang.NO' > > ) > > ) > > as title_text_value from article where NOT title_text_value is NULL; > > > > ERROR: Attribute 'title_text_value' not found > > Hallo Andreas, > > Relocating your AS clause to the topmost string? BTW, table aliasing > would make for less typing. > > Best of luck! I don't get it, what do you mean by "Relocating your AS clause to the topmost string"? -- Andreas Joseph Krogh <andreak@officenet.no>
Re: Referencing named attribute in where clause doesn't work with 7.1.2?
From
Peter Eisentraut
Date:
Andreas Joseph Krogh writes: > Hi, this is my first post to this list so please... > I have problems getting this query to work, any ideas? > > select article.title_text_key, > (select on_text.text_value from on_text where > on_text.text_key = title_text_key > AND NOT title_text_key is NULL > AND on_text.lang_id = (select code.id from code, code_group where > code.code_group_id = code_group.id > AND code_group.description = 'lang' AND code.code_key = 'lang.NO' > ) > ) > as title_text_value from article where NOT title_text_value is NULL; > > ERROR: Attribute 'title_text_value' not found The select list is not in scope for the where clause. Basically, the order of processing and approximately the nesting of scopes is: from -> where -> group -> having -> select -> order Any names generated by an element on the right cannot be in scope in elements on the left. (In some cases it might work as a convenience anyway, but not in your case.) I think you might be better off writing this query as a proper join anyway. -- Peter Eisentraut peter_e@gmx.net http://funkturm.homeip.net/~peter