Solved

Update statement with Select and Joined tables? [Firebird]

Posted on 2009-04-12
3
3,504 Views
Last Modified: 2013-12-09
Hello all,

Need help in getting a query to work. In order to get the 'value/result' I want I need a result which is based on two tables. I have tried several different alternatives, but failed to get it working..

Basically what it's doing is counting the value of a player's price (sports sim) which is based on the players offensive(Off) and defensive(Def) as well as the team's reputation(T.Rep).

As mentioned in the title I'm working with Firebird databases.

I'm a beginner, so bare with me please :)
update Players set P.Value = P.Off+P.Def+T.Rep (select P.*, T.* from Team T join Players P on T.Club = P.Club)

Open in new window

0
Comment
Question by:MerlaP83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 24125576
The change should bo following:
UPDATE Players SET Value = P.Off+P.Def+T.Rep
  FROM Players P
 INNER JOIN Team T on T.Club = P.Club

Open in new window

0
 

Author Comment

by:MerlaP83
ID: 24125594
Thanks for your reply.

I do get the error msg "SQL Error:  Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 48 FROM. Error Code: -104." Seems a bit weird.
0
 
LVL 42

Accepted Solution

by:
pcelba earned 125 total points
ID: 24125637
Sorry, Firebird does not support this syntax which is obvious for SQL Server, so, please try this:
UPDATE Players P 
   SET P.Value = P.Off+P.Def + (SELECT T.Rep FROM Team T WHERE T.Club = P.Club)

Open in new window

0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question