Solved

Update statement with Select and Joined tables? [Firebird]

Posted on 2009-04-12
3
3,169 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

943 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

6 Experts available now in Live!

Get 1:1 Help Now