From: Martin Gainty Date: August 16 2008 2:49pm Subject: RE: Multiple Query/Insert help List-Archive: http://lists.mysql.com/mysql/214136 Message-Id: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="_0d466ad3-e478-48bf-b517-2f623768b459_" --_0d466ad3-e478-48bf-b517-2f623768b459_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable the only possible suggestion i have would be to disambiguate the selected c= olumns with 'as' insert into games2 (sea_id=2Cdate=2Ctime=2Cloc_id=2Chteam=2Cvteam=2Cdiv_id)= =20 ( select '36' as sea_id=2C game_date as date=2C begin_time as time=2C loc_id as loc= _id=2C home_team_id as hteam=2C away_team_id as vteam=2C ts.div_id as div_u= d > from > scheduler s1 INNER JOIN team_season ts ON ts.team_id =3D s1.div_id > ) Thanks Andy Martin=20 ______________________________________________=20 Disclaimer and confidentiality note=20 Everything in this e-mail and any attachments relates to the official busin= ess of Sender. This transmission is of a confidential nature and Sender doe= s not endorse distribution to any party other than intended recipient. Send= er does not necessarily endorse content contained within this transmission.= =20 > Date: Sat=2C 16 Aug 2008 15:40:08 +0100 > From: andy.shellam-lists@stripped > To: steve@stripped > CC: mysql@stripped > Subject: Re: Multiple Query/Insert help >=20 > Hi Steve=2C >=20 > You're seeing this error because this query: >=20 > select div_id > from team_season where team_id=3Ds1.div_id >=20 > is being run independently of the rest=2C so it doesn't know of "s1" in=20 > this context. You would probably be better with an INNER JOIN here=2C=20 > something like the following (may need tweaking): >=20 > e.g. >=20 > insert into games2 (sea_id=2Cdate=2Ctime=2Cloc_id=2Chteam=2Cvteam=2Cdiv_i= d)=20 > ( > select > '36'=2C game_date=2C begin_time=2C loc_id=2C home_team_id=2C away_team_= id=2C ts.div_id > from > scheduler s1 INNER JOIN team_season ts ON ts.team_id =3D s1.div_id > ) >=20 >=20 > Regards=2C > Andy >=20 > Steven Buehler wrote: > > I have a query that I just can't seem to get working. > > > > =20 > > > > insert into games2 (sea_id=2Cdate=2Ctime=2Cloc_id=2Chteam=2Cvteam=2Cdiv= _id) (select > > '36'=2Cgame_date=2Cbegin_time=2Cloc_id=2Chome_team_id=2Caway_team_id=2C= (select div_id > > from team_season where team_id=3Ds1.div_id) from scheduler s1)=3B > > > > =20 > > > > Of course=2C I am getting the dreaded "Unknown column 's1.div_id' in 'w= here > > clause'" error message. > > > > I think the statement above shows what I am trying to do better than me > > explaining it. My only real problem is that the div_id needs to be got= ten > > from the team_season table. > > > > =20 > > > > Any help would be appreciated > > > > Thanks > > > > Steve > > > > > > =20 >=20 > --=20 > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dmgainty@stripped= om >=20 _________________________________________________________________ See what people are saying about Windows Live. Check out featured posts. http://www.windowslive.com/connect?ocid=3DTXT_TAGLM_WL_connect2_082008= --_0d466ad3-e478-48bf-b517-2f623768b459_--