Sorry, I forgot. I work almost exclusively with virtual tables...

Gunter

-----Ursprüngliche Nachricht-----
Von: Igor Korot [mailto:ikoro...@gmail.com]
Gesendet: Freitag, 25. Oktober 2013 09:57
An: General Discussion of SQLite Database
Betreff: Re: [sqlite] Is this a proper syntax?

Hi, Hick,


On Fri, Oct 25, 2013 at 12:52 AM, Hick Gunter <h...@scigames.at> wrote:

> How did you populate the first two fields of the leagueplayers relation?
>
> Since SQLite doesn't do ALTER TABLE ADD COLUMN there must have been an
> old leagueplayers table without the new fields.
>

SQLite does support ALTER TABLE ADD syntax.

Thank you.


>
> So why not
>
> INSERT INTO <new table> SELECT o.playerid,o.leagueid,p.rank,p.rank
> from <old table> o LEFT JOIN players p ON o.playerid = p.playerid;
>
> and add the values for the new fields during the initial load?
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Korot [mailto:ikoro...@gmail.com]
> Gesendet: Freitag, 25. Oktober 2013 01:35
> An: General Discussion of SQLite Database
> Betreff: Re: [sqlite] Is this a proper syntax?
>
> Igor,
>
>
> On Thu, Oct 24, 2013 at 12:57 PM, Igor Tandetnik <i...@tandetnik.org>
> wrote:
>
> > On 10/24/2013 3:23 PM, Igor Korot wrote:
> >
> >> Will this query work:
> >>
> >> UPDATE a SET a.field1 = (SELECT b.field1 FROM b AS myfield),
> >> a.field2 = myfield...
> >>
> >> or I will have to repeat subquery for a.field2?
> >>
> >
> > I'm pretty sure you will have to repeat the subquery. In your
> > statement, myfield is an (unused) alias for table b, not for a value
> > produced by the subquery (which I don't know of any way to name or
> reuse).
> >
>
> Well, let me try to explain myself.
> Consider following schema:
>
> CREATE TABLE players( playerid INTEGER, name TEXT, rank INTEGER,
> PRIMARY KEY playerid); CREATE TABLE leagueplayers(playerid INTEGER,
> leagueid INTEGER, original_rank INTEGER, current_rank INTEGER);
>
> The players table is populated.
> What I'm trying to do is to populate the second table with the last 2
> fields: original_rank and current_rank.
>
> So I was thinking of something like this:
>
> UPDATE leagueplayers SET original_rank = (SELECT rank FROM players AS
> a), current_rank= a WHERE players.playerid = leagueplayers.playerid;
>
> But I guess this query will not work. ;-)
>
> Any idea how to make the proper query?
>
> Thank you.
>
> --
> > Igor Tandetnik
> >
> >
> > ______________________________**_________________
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<http:
> > //sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
> >
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
> ----------------------------------------------------------------------
> ----
>  Gunter Hick
> Software Engineer
> Scientific Games International GmbH
> Klitschgasse 2 - 4, A - 1130 Vienna, Austria FN 157284 a, HG Wien
> Tel: +43 1 80100 0
> E-Mail: h...@scigames.at
>
> This e-mail is confidential and may well also be legally privileged.
> If you have received it in error, you are on notice as to its status
> and accordingly please notify us immediately by reply e-mail and then
> delete this message from your system. Please do not copy it or use it
> for any purposes, or disclose its contents to any person as to do so
> could be a breach of confidence. Thank you for your cooperation.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


--------------------------------------------------------------------------
 Gunter Hick
Software Engineer
Scientific Games International GmbH
Klitschgasse 2 – 4, A - 1130 Vienna, Austria
FN 157284 a, HG Wien
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This e-mail is confidential and may well also be legally privileged. If you 
have received it in error, you are on notice as to its status and accordingly 
please notify us immediately by reply e-mail and then delete this message from 
your system. Please do not copy it or use it for any purposes, or disclose its 
contents to any person as to do so could be a breach of confidence. Thank you 
for your cooperation.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to