Understanding SELECT statement

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Understanding SELECT statement

csanyipal
Hi,

I have the 'SchoolYearTeachingDays' table with just one column, in
which are dates:

CREATE TABLE SchoolYearTeachingDays (
    aDate DATE PRIMARY KEY
                UNIQUE
);
I filled it with many dates which are unique. These dates excludes
dates for Sundays and for Saturdays. I have another, the
'TeachingSaturdaysInSchoolYear' table:

CREATE TABLE TeachingSaturdaysInSchoolYear (
    id            INT  PRIMARY KEY
                       UNIQUE,
    aDate      DATE,
    TimetableForTheDay TEXT
);
This table holds just two dates. These two dates are for two
Saturdays. On these two Saturdays we have to teach students. When I do
the following query on this table, I get these two records:

2018-04-14
2018-05-05

I want to INSERT these two dates from the
'TeachingSaturdaysInSchoolYear' table into 'SchoolYearTeachingDays'
table.

I am trying with this query:

INSERT INTO SchoolYearTeachingDays
 SELECT aDate FROM TeachingSaturdaysInSchoolYear
;
but I get this error: Error: UNIQUE constraint failed:
SchoolYearTeachingDays.aDate

Then I get help and this code:
INSERT INTO SchoolYearTeachingDays
 SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
IN (SELECT S.aDate FROM SchoolYearTeachingDays S)

It works. But I am not understanding it at all.
I wish to know followings.
How many times want to inserts the SELECT query the one of the date
from the TeachingSaturdaysInSchoolYear table into
SchoolYearTeachingDays table?

That is: the how many times wants select statement to insert one
record from first table into second table?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Best, Pál
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

Igor Tandetnik-2
On 6/26/2018 9:15 AM, Csányi Pál wrote:

> I have the 'SchoolYearTeachingDays' table with just one column, in
> which are dates:
>
> CREATE TABLE SchoolYearTeachingDays (
>      aDate DATE PRIMARY KEY
>                  UNIQUE
> );
> I filled it with many dates which are unique. These dates excludes
> dates for Sundays and for Saturdays. I have another, the
> 'TeachingSaturdaysInSchoolYear' table:
>
> CREATE TABLE TeachingSaturdaysInSchoolYear (
>      id            INT  PRIMARY KEY
>                         UNIQUE,
>      aDate      DATE,
>      TimetableForTheDay TEXT
> );
> This table holds just two dates. These two dates are for two
> Saturdays. On these two Saturdays we have to teach students. When I do
> the following query on this table, I get these two records:
>
> 2018-04-14
> 2018-05-05
>
> I want to INSERT these two dates from the
> 'TeachingSaturdaysInSchoolYear' table into 'SchoolYearTeachingDays'
> table.
>
> I am trying with this query:
>
> INSERT INTO SchoolYearTeachingDays
>   SELECT aDate FROM TeachingSaturdaysInSchoolYear
> ;
> but I get this error: Error: UNIQUE constraint failed:
> SchoolYearTeachingDays.aDate

This means that, despite your assumption to the contrary, at least one of those two dates is already present in SchoolYearTeachingDays

> Then I get help and this code:
> INSERT INTO SchoolYearTeachingDays
>   SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
> IN (SELECT S.aDate FROM SchoolYearTeachingDays S)

This says "insert all dates that aren't already present", which of course avoids UNIQUE constraint.

> I wish to know followings.
> How many times want to inserts the SELECT query the one of the date
> from the TeachingSaturdaysInSchoolYear table into
> SchoolYearTeachingDays table?

I don't understand this question.

> That is: the how many times wants select statement to insert one
> record from first table into second table?

Each row in the resultset of SELECT statement is inserted once, of course.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Understanding SELECT statement

Hick Gunter
In reply to this post by csanyipal
There is no DATE datatype in SQLite. Your declaration assigns NUMERIC affinity for the date column.

It seems that you are storing TEXT values, which is allowed, but in conflict with your declaration.

Since you have not declared INTEGER PRIMARY KEY, you only achieve what UNIQUE alone would have done.

As SQLite is asserting a UNIQUE constraint violation, you have probably already inserted at least one saturday into your SchoolYearTeachingDays table. You can check this with:

SELECT rowid, aDate FROM SchoolYearTeachingDays WHERE aDate IN (SELECT aDate FROM TeachingSaturdaysInSchoolYear);

Or you may have duplicate dates (you did not declare aDate to be UNIQUE in that table) in your TeachingSaturdaysInSchoolYear table, which you can check with:

SELECT aDate,count() from TeachingSaturdaysInSchoolYear group by 1 order by 1;

To answer your question: INSERT INTO ... SELECT will attempt to insert each result row of the SELECT exactly once. If you want to insert duplicated rows of the SELECT only once, you need to SELECT DISTINCT.


-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Csányi Pál
Gesendet: Dienstag, 26. Juni 2018 15:15
An: SQlite User <[hidden email]>
Betreff: [EXTERNAL] [sqlite] Understanding SELECT statement

Hi,

I have the 'SchoolYearTeachingDays' table with just one column, in which are dates:

CREATE TABLE SchoolYearTeachingDays (
    aDate DATE PRIMARY KEY
                UNIQUE
);
I filled it with many dates which are unique. These dates excludes dates for Sundays and for Saturdays. I have another, the 'TeachingSaturdaysInSchoolYear' table:

CREATE TABLE TeachingSaturdaysInSchoolYear (
    id            INT  PRIMARY KEY
                       UNIQUE,
    aDate      DATE,
    TimetableForTheDay TEXT
);
This table holds just two dates. These two dates are for two Saturdays. On these two Saturdays we have to teach students. When I do the following query on this table, I get these two records:

2018-04-14
2018-05-05

I want to INSERT these two dates from the 'TeachingSaturdaysInSchoolYear' table into 'SchoolYearTeachingDays'
table.

I am trying with this query:

INSERT INTO SchoolYearTeachingDays
 SELECT aDate FROM TeachingSaturdaysInSchoolYear ; but I get this error: Error: UNIQUE constraint failed:
SchoolYearTeachingDays.aDate

Then I get help and this code:
INSERT INTO SchoolYearTeachingDays
 SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT IN (SELECT S.aDate FROM SchoolYearTeachingDays S)

It works. But I am not understanding it at all.
I wish to know followings.
How many times want to inserts the SELECT query the one of the date from the TeachingSaturdaysInSchoolYear table into SchoolYearTeachingDays table?

That is: the how many times wants select statement to insert one record from first table into second table?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] Understanding SELECT statement

csanyipal
I understand now a little better, how SELECT statement works.

Thank you all for the explanations.

Hick Gunter <[hidden email]> ezt írta (időpont: 2018. jún. 26., K, 16:23):

>
> There is no DATE datatype in SQLite. Your declaration assigns NUMERIC affinity for the date column.
>
> It seems that you are storing TEXT values, which is allowed, but in conflict with your declaration.
>
> Since you have not declared INTEGER PRIMARY KEY, you only achieve what UNIQUE alone would have done.
>
> As SQLite is asserting a UNIQUE constraint violation, you have probably already inserted at least one saturday into your SchoolYearTeachingDays table. You can check this with:
>
> SELECT rowid, aDate FROM SchoolYearTeachingDays WHERE aDate IN (SELECT aDate FROM TeachingSaturdaysInSchoolYear);
>
> Or you may have duplicate dates (you did not declare aDate to be UNIQUE in that table) in your TeachingSaturdaysInSchoolYear table, which you can check with:
>
> SELECT aDate,count() from TeachingSaturdaysInSchoolYear group by 1 order by 1;
>
> To answer your question: INSERT INTO ... SELECT will attempt to insert each result row of the SELECT exactly once. If you want to insert duplicated rows of the SELECT only once, you need to SELECT DISTINCT.
>
>
> -----Ursprüngliche Nachricht-----
> Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Csányi Pál
> Gesendet: Dienstag, 26. Juni 2018 15:15
> An: SQlite User <[hidden email]>
> Betreff: [EXTERNAL] [sqlite] Understanding SELECT statement
>
> Hi,
>
> I have the 'SchoolYearTeachingDays' table with just one column, in which are dates:
>
> CREATE TABLE SchoolYearTeachingDays (
>     aDate DATE PRIMARY KEY
>                 UNIQUE
> );
> I filled it with many dates which are unique. These dates excludes dates for Sundays and for Saturdays. I have another, the 'TeachingSaturdaysInSchoolYear' table:
>
> CREATE TABLE TeachingSaturdaysInSchoolYear (
>     id            INT  PRIMARY KEY
>                        UNIQUE,
>     aDate      DATE,
>     TimetableForTheDay TEXT
> );
> This table holds just two dates. These two dates are for two Saturdays. On these two Saturdays we have to teach students. When I do the following query on this table, I get these two records:
>
> 2018-04-14
> 2018-05-05
>
> I want to INSERT these two dates from the 'TeachingSaturdaysInSchoolYear' table into 'SchoolYearTeachingDays'
> table.
>
> I am trying with this query:
>
> INSERT INTO SchoolYearTeachingDays
>  SELECT aDate FROM TeachingSaturdaysInSchoolYear ; but I get this error: Error: UNIQUE constraint failed:
> SchoolYearTeachingDays.aDate
>
> Then I get help and this code:
> INSERT INTO SchoolYearTeachingDays
>  SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
>
> It works. But I am not understanding it at all.
> I wish to know followings.
> How many times want to inserts the SELECT query the one of the date from the TeachingSaturdaysInSchoolYear table into SchoolYearTeachingDays table?
>
> That is: the how many times wants select statement to insert one record from first table into second table?
>
> --
> Best, Pali
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
>
> ___________________________________________
>  Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0
>
> May be privileged. May be confidential. Please delete if not the addressee.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Best, Pál
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

csanyipal
In reply to this post by Igor Tandetnik-2
Igor Tandetnik <[hidden email]> ezt írta (időpont: 2018. jún. 26.,
K, 16:10):
>
> On 6/26/2018 9:15 AM, Csányi Pál wrote:

> > Then I get help and this code:
> > INSERT INTO SchoolYearTeachingDays
> >   SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
> > IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
>
> This says "insert all dates that aren't already present", which of course avoids UNIQUE constraint.

Just do not understand what are the 'T' and 'S' means out there, after
FROM clause.
Are they CTEs? Are they virtual tables?

--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Best, Pál
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

Andy Ling-2
In reply to this post by csanyipal
> > > Then I get help and this code:
> > > INSERT INTO SchoolYearTeachingDays
> > >   SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate
> NOT
> > > IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
> >
> > This says "insert all dates that aren't already present", which of course
> avoids UNIQUE constraint.
>
> Just do not understand what are the 'T' and 'S' means out there, after
> FROM clause.
> Are they CTEs? Are they virtual tables?
>

They are aliases for the table names. Another way of writing this is

SELECT aDate FROM TeachingSaturdaysInSchoolYear AS T WHERE T.aDate

The AS is optional, but makes it slightly clearer that you are saying use
the table TeachingSaturdaysInSchoolYear and call it T. In this case
it is a way of saving typing.

Regards

Andy Ling
---------------------------------------------------------------------------------------
This email has been scanned for email related threats and delivered safely by Mimecast.
For more information please visit http://www.mimecast.com
---------------------------------------------------------------------------------------

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

Igor Tandetnik-2
In reply to this post by csanyipal
On 6/26/2018 10:42 AM, Csányi Pál wrote:

> Igor Tandetnik <[hidden email]> ezt írta (időpont: 2018. jún. 26.,
> K, 16:10):
>>
>> On 6/26/2018 9:15 AM, Csányi Pál wrote:
>
>>> Then I get help and this code:
>>> INSERT INTO SchoolYearTeachingDays
>>>    SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
>>> IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
>>
>> This says "insert all dates that aren't already present", which of course avoids UNIQUE constraint.
>
> Just do not understand what are the 'T' and 'S' means out there, after
> FROM clause.
> Are they CTEs? Are they virtual tables?

They are aliases. You could write TeachingSaturdaysInSchoolYear.aDate in place of T.aDate without a change in meaning; T.aDate is merely shorter and more convenient.
--
Igor Tandetnik


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

Simon Slavin-3
In reply to this post by csanyipal


> On 26 Jun 2018, at 3:42pm, Csányi Pál <[hidden email]> wrote:
>
>>> INSERT INTO SchoolYearTeachingDays
>>>  SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
>>> IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
>
> Just do not understand what are the 'T' and 'S' means out there, after
> FROM clause.

This is from an old stupid syntax for SQL.  In more modern SQL we would write

    SELECT aDate FROM TeachingSaturdaysInSchoolYear AS T WHERE T.aDate NOT IN (SELECT S.aDate FROM SchoolYearTeachingDays AS S)

It works for backwards compatibility but the "AS" makes the sense clearer.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

R Smith-2
In reply to this post by csanyipal

On 2018/06/26 4:42 PM, Csányi Pál wrote:

>
>>> Then I get help and this code:
>>> INSERT INTO SchoolYearTeachingDays
>>>    SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
>>> IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
>> This says "insert all dates that aren't already present", which of course avoids UNIQUE constraint.
> Just do not understand what are the 'T' and 'S' means out there, after
> FROM clause.
> Are they CTEs? Are they virtual tables?
>

The T and S are substitute identifiers that represent the tables
"SchoolYearTeachingDays" and "TeachingSaturdaysInSchoolYear".  These
substitute names are called "Aliases" which is something like a
short-name or nick-name for something with a long name which we do not
want to type every time.  Much like in school when someone was named
"Josephine" but everyone just called her "Jo" for short, then "Jo" is an
Alias for "Josephine", like in the above query where "S" is an alias for
"SchoolYearTeachingDays".

The main reason we use aliases, which other posts have highlighted
already, is simply to spare ourselves the effort of having to type it
out many times, but it's also handy for avoiding confusion when we have
two references to the same table, or two tables with column names that
are the same.

In the query above, the reason we need to name the table is so that we
make sure the "aDate" in the SELECT refers to the aDate from the
"SchoolYearTeachingDays" table in the correlated sub-query (the bit
inside parentheses) and not the outside query, which refers to table
"TeachingSaturdaysInSchoolYear", which may also have an "aDate" column.
So to avoid ambiguity or confusion about which aDate we are talking
about, we must specify the table it is in. But we don't want to write
the full table name every time, so in stead we use the aliases.

One way to tell SQL we intend to use an alias is to use an "AS" clause,
so we could say:

SELECT A.id FROM MyLongNamedTable AS A WHERE A.id > 5
Here we say we will get data from "MyLongNamedTable" but we will use it
AS if it was named "A" so that everywhere else we will be able to refer
to A.this or A.that in stead of having to type MyLongNamedTable.this and
MyLongNamedTable.that.

We can also do this for column names in the return header, so if I want
to get the id from MyTable but we want it to be more descriptive, we
could do:
SELECT id AS MyTableID FROM MyTable...
This will output a list of IDs under the aliased heading: "MyTableID".

Lastly, as Simon mentioned, the SQL standard allows us to drop the word
"AS" as long as we specify the known identifier directly followed by its
Alias, so the previous query can also be written like:
SELECT id MyTableID FROM MyTable...

There is a school of thought that prefers this "id MyTableID" aliasing
due to its brevity, and another that prefers the full "id AS MyTableID"
due to its clarity.
I don't think there is a "Right" way. Personally I use the first in my
actual queries, but the second when using a query in an explanation.


Hope that makes it clear.

PS: Apologies for the overly "wordy" response, but it seems to me the OP
is not natively English, or might read this through a translator, and I
find for those to make sense in a technical translation, it is best if
they have a lot of data to work with, saying the same thing in different
ways, etc.



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

csanyipal
Once again, thank you all very much for your help.
I understand now this query.

R Smith <[hidden email]> ezt írta (időpont: 2018. jún. 26., K, 17:28):

>
>
> On 2018/06/26 4:42 PM, Csányi Pál wrote:
> >
> >>> Then I get help and this code:
> >>> INSERT INTO SchoolYearTeachingDays
> >>>    SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate NOT
> >>> IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
> >> This says "insert all dates that aren't already present", which of course avoids UNIQUE constraint.
> > Just do not understand what are the 'T' and 'S' means out there, after
> > FROM clause.
> > Are they CTEs? Are they virtual tables?
> >
>
> The T and S are substitute identifiers that represent the tables
> "SchoolYearTeachingDays" and "TeachingSaturdaysInSchoolYear".  These
> substitute names are called "Aliases" which is something like a
> short-name or nick-name for something with a long name which we do not
> want to type every time.  Much like in school when someone was named
> "Josephine" but everyone just called her "Jo" for short, then "Jo" is an
> Alias for "Josephine", like in the above query where "S" is an alias for
> "SchoolYearTeachingDays".
>
> The main reason we use aliases, which other posts have highlighted
> already, is simply to spare ourselves the effort of having to type it
> out many times, but it's also handy for avoiding confusion when we have
> two references to the same table, or two tables with column names that
> are the same.
>
> In the query above, the reason we need to name the table is so that we
> make sure the "aDate" in the SELECT refers to the aDate from the
> "SchoolYearTeachingDays" table in the correlated sub-query (the bit
> inside parentheses) and not the outside query, which refers to table
> "TeachingSaturdaysInSchoolYear", which may also have an "aDate" column.
> So to avoid ambiguity or confusion about which aDate we are talking
> about, we must specify the table it is in. But we don't want to write
> the full table name every time, so in stead we use the aliases.
>
> One way to tell SQL we intend to use an alias is to use an "AS" clause,
> so we could say:
>
> SELECT A.id FROM MyLongNamedTable AS A WHERE A.id > 5
> Here we say we will get data from "MyLongNamedTable" but we will use it
> AS if it was named "A" so that everywhere else we will be able to refer
> to A.this or A.that in stead of having to type MyLongNamedTable.this and
> MyLongNamedTable.that.
>
> We can also do this for column names in the return header, so if I want
> to get the id from MyTable but we want it to be more descriptive, we
> could do:
> SELECT id AS MyTableID FROM MyTable...
> This will output a list of IDs under the aliased heading: "MyTableID".
>
> Lastly, as Simon mentioned, the SQL standard allows us to drop the word
> "AS" as long as we specify the known identifier directly followed by its
> Alias, so the previous query can also be written like:
> SELECT id MyTableID FROM MyTable...
>
> There is a school of thought that prefers this "id MyTableID" aliasing
> due to its brevity, and another that prefers the full "id AS MyTableID"
> due to its clarity.
> I don't think there is a "Right" way. Personally I use the first in my
> actual queries, but the second when using a query in an explanation.
>
>
> Hope that makes it clear.
>
> PS: Apologies for the overly "wordy" response, but it seems to me the OP
> is not natively English, or might read this through a translator, and I
> find for those to make sense in a technical translation, it is best if
> they have a lot of data to work with, saying the same thing in different
> ways, etc.
>
>
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



--
Best, Pali
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Best, Pál
Reply | Threaded
Open this post in threaded view
|

Re: Understanding SELECT statement

Keith Medcalf
In reply to this post by Simon Slavin-3

Actually, you would probably write:

SELECT aDate
  FROM TeachingSaturdaysInSchoolYear
 WHERE aDate NOT IN (SELECT aDate
                       FROM SchoolYearTeachingDays);

Since the subquery is not correlated there is no *need* for aliases ... but if you want to type more characters you are free to do so ...

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Simon Slavin
>Sent: Tuesday, 26 June, 2018 08:56
>To: SQLite mailing list
>Subject: Re: [sqlite] Understanding SELECT statement
>
>
>
>> On 26 Jun 2018, at 3:42pm, Csányi Pál <[hidden email]> wrote:
>>
>>>> INSERT INTO SchoolYearTeachingDays
>>>>  SELECT aDate FROM TeachingSaturdaysInSchoolYear T WHERE T.aDate
>NOT
>>>> IN (SELECT S.aDate FROM SchoolYearTeachingDays S)
>>
>> Just do not understand what are the 'T' and 'S' means out there,
>after
>> FROM clause.
>
>This is from an old stupid syntax for SQL.  In more modern SQL we
>would write
>
>    SELECT aDate FROM TeachingSaturdaysInSchoolYear AS T WHERE
>T.aDate NOT IN (SELECT S.aDate FROM SchoolYearTeachingDays AS S)
>
>It works for backwards compatibility but the "AS" makes the sense
>clearer.
>
>Simon.
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users