Solved

Update statement with Select and Joined tables? [Firebird]

Posted on 2009-04-12
3
3,233 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
  • 2
3 Comments
 
LVL 41

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 41

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

816 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now