![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Ok, "question" one - I'm pretty sure I know the answer to this: Given: CREATE TABLE A ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE B ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? |
|
Ok, now that we have that out of the way, question two: CREATE TABLE A ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE B ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE C ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE D ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) If we issue the query: A INNER JOIN B (USING id) INNER JOIN C (USING id) INNER JOIN D (USING id) and we know that there are zero rows in common between C and D, can we not conclude with 100% certainty that the overall result will be zero rows? |
|
Finally: what books do you recommend for learning about SQL and databases? I liked "SQL Queries for Mere Mortals" by Viescas and Michael J. Hernandez, but maybe it was not elementary enough for me. Maybe even a good web tutorial is fine, but I need to re-lock down my basics. |
#3
| |||
| |||
|
|
metaperl wrote: if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? Correct, eventhough I'm unfamiliar with the syntax you have used. Standard sql would have been: A INNER JOIN B on A.id = B.id |
#4
| |||
| |||
|
|
On Jul 3, 11:20 am, Lennart <erik.lennart.jons... (AT) gmail (DOT) com> wrote: metaperl wrote: if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? Correct, eventhough I'm unfamiliar with the syntax you have used. Standard sql would have been: A INNER JOIN B on A.id = B.id It's MySQL syntax. |
#5
| |||
| |||
|
|
"metaperl" <metaperl (AT) gmail (DOT) com> wrote in message news:1183479129.413645.94790 (AT) w5g2000hsg (DOT) googlegroups.com... On Jul 3, 11:20 am, Lennart <erik.lennart.jons... (AT) gmail (DOT) com> wrote: metaperl wrote: if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? Correct, eventhough I'm unfamiliar with the syntax you have used. Standard sql would have been: A INNER JOIN B on A.id = B.id It's MySQL syntax. It is in fact ANSI/ISO SQL-92 standard syntax. |
|
Roy |
#6
| |||
| |||
|
|
On Jul 3, 11:20 am, Lennart <erik.lennart.jons... (AT) gmail (DOT) com> wrote: metaperl wrote: if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? Correct, eventhough I'm unfamiliar with the syntax you have used. Standard sql would have been: A INNER JOIN B on A.id = B.id It's MySQL syntax. |
#7
| |||
| |||
|
|
Roy Hann wrote: [...] It is in fact ANSI/ISO SQL-92 standard syntax. Yes, you're right. I never saw that before and figured it was one of those mysql invented thingies. I checked against sql2003 and did not find this kind of join. When I checked again, there it was. I dont understand how I could miss it. Thanks for the correction |
#8
| |||
| |||
|
|
Ok, "question" one - I'm pretty sure I know the answer to this: Given: CREATE TABLE A ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE B ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) |
|
if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? Ok, now that we have that out of the way, question two: CREATE TABLE A ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE B ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE C ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE D ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) If we issue the query: A INNER JOIN B (USING id) INNER JOIN C (USING id) INNER JOIN D (USING id) and we know that there are zero rows in common between C and D, can we not conclude with 100% certainty that the overall result will be zero rows? Finally: what books do you recommend for learning about SQL and databases? I liked "SQL Queries for Mere Mortals" by Viescas and Michael J. Hernandez, but maybe it was not elementary enough for me. Maybe even a good web tutorial is fine, but I need to re-lock down my basics. Thanks! |
#9
| |||
| |||
|
|
Ok, "question" one - I'm pretty sure I know the answer to this: Given: CREATE TABLE A ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE B ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) if B contains now rows then A INNER JOIN B (USING id) will return zero rows, correct? Ok, now that we have that out of the way, question two: CREATE TABLE A ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE B ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE C ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) CREATE TABLE D ( INTEGER PRIMARY KEY AUTOINCREMENT id, VARCHAR(255) value ) If we issue the query: A INNER JOIN B (USING id) INNER JOIN C (USING id) INNER JOIN D (USING id) and we know that there are zero rows in common between C and D, can we not conclude with 100% certainty that the overall result will be zero rows? |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |