Received: from slip1.raccoon.com (slip1.raccoon.com [165.90.135.16]) by hub.org (8.9.2/8.9.1) with ESMTP id XAA18777 for ; Thu, 18 Mar 1999 23:15:18 -0500 (EST) (envelope-from perdue@raccoon.com) Received: from timnt (tim.desmoinesnet.com [165.90.140.11]) by slip1.raccoon.com (8.8.7/8.8.7) with SMTP id WAA11178; Thu, 18 Mar 1999 22:14:42 -0600 Message-ID: <013b01be71be$e551f0b0$0b8c5aa5@timnt.weather.net> Reply-To: "Tim Perdue" From: "Tim Perdue" To: , Subject: Re: [SQL] Stuck on SQL - Any Takers? Date: Thu, 18 Mar 1999 22:13:50 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Here are the tables. The first table is not really designed very well. Each record has nine fields that has a athlete_no in it. That athlete_no relates to tbl_athlete_stats. For each record in tbl_teams, I want to pull the corresponding scores out of tbl_athlete_stats and create a new table, tbl_ranked_teams2. My query (at the bottom) does not error out, but it never inserts any records or completes. tbl_teams ( fld_team_no int primary key, fld_cust_no int, fld_athlete1 int, --> fld_player_number in tbl_athlete_stats fld_athlete2 int, --> fld_player_number in tbl_athlete_stats fld_athlete3 int, --> fld_player_number in tbl_athlete_stats fld_athlete4 int, --> fld_player_number in tbl_athlete_stats fld_athlete5 int, --> fld_player_number in tbl_athlete_stats fld_athlete6 int, --> fld_player_number in tbl_athlete_stats fld_athlete7 int, --> fld_player_number in tbl_athlete_stats fld_athlete8 int, --> fld_player_number in tbl_athlete_stats fld_athlete9 int --> fld_player_number in tbl_athlete_stats ); tbl_athlete_stats ( fld_player_number int primary key, fld_player_last text, fld_player_first text, fld_player_id int, fld_team text, fld_position text, fld_batting_ave float4, fld_singles int, fld_doubles int, fld_triples int, fld_home_runs int, fld_rbis int, fld_walks int, fld_teals int, fld_runs int, fld_total_points_wk int, fld_total_points_ytd int ); create table tbl_ranked_teams2 ( fld_team_no int, fld_athlete1_ytd int, fld_athlete2_ytd int, fld_athlete3_ytd int, fld_athlete4_ytd int, fld_athlete5_ytd int, fld_athlete6_ytd int, fld_athlete7_ytd int, fld_athlete8_ytd int, fld_athlete9_ytd int ); insert into tbl_ranked_teams2 SELECT tbl_teams.fld_team_no, tbl_athlete_stats_1.fld_total_points_ytd, tbl_athlete_stats_2.fld_total_points_ytd, tbl_athlete_stats_3.fld_total_points_ytd, tbl_athlete_stats_4.fld_total_points_ytd, tbl_athlete_stats_5.fld_total_points_ytd, tbl_athlete_stats_6.fld_total_points_ytd, tbl_athlete_stats_7.fld_total_points_ytd, tbl_athlete_stats_8.fld_total_points_ytd, tbl_athlete_stats_9.fld_total_points_ytd FROM tbl_athlete_stats tbl_athlete_stats_1, tbl_athlete_stats tbl_athlete_stats_2, tbl_athlete_stats tbl_athlete_stats_3, tbl_athlete_stats tbl_athlete_stats_4, tbl_athlete_stats tbl_athlete_stats_5, tbl_athlete_stats tbl_athlete_stats_6, tbl_athlete_stats tbl_athlete_stats_7, tbl_athlete_stats tbl_athlete_stats_8, tbl_athlete_stats tbl_athlete_stats_9 WHERE tbl_athlete_stats_1.fld_player_number = tbl_teams.fld_athlete1 and tbl_athlete_stats_2.fld_player_number = tbl_teams.fld_athlete2 and tbl_athlete_stats_3.fld_player_number = tbl_teams.fld_athlete3 and tbl_athlete_stats_4.fld_player_number = tbl_teams.fld_athlete4 and tbl_athlete_stats_5.fld_player_number = tbl_teams.fld_athlete5 and tbl_athlete_stats_6.fld_player_number = tbl_teams.fld_athlete6 and tbl_athlete_stats_7.fld_player_number = tbl_teams.fld_athlete7 and tbl_athlete_stats_8.fld_player_number = tbl_teams.fld_athlete8 and tbl_athlete_stats_9.fld_player_number = tbl_teams.fld_athlete9;