Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Cool!

    I think I must review what the "CROSS JOIN" does in my SQL manual... :-)
    Thanks for sharing.
    • CROSS JOIN is simply an explicit way to request the standard cartesian product.

      sqlite> CREATE TABLE tbl (num INTEGER);
      sqlite> INSERT INTO tbl VALUES (  1);
      sqlite> INSERT INTO tbl VALUES (  2);
      sqlite> INSERT INTO tbl VALUES (  3);
      sqlite> SELECT t1.num A, t2.num B FROM tbl t1 CROSS JOIN tbl t2;
      A           B
      ----------  ----------
      1           1
      1           2
      1           3
      2           1
      2           2
      2           3
      3           1
      3           2
      3           3

      You can write the exact same query like this:

      SELECT t1.num A, t2.num B FROM tbl t1, tbl t2

      I just prefer the newer syntax because there are few cases where you’d deliberately ask for a cartesian product, and with the old syntax it’s not clear whether you did so or merely forgot the join condition. The new explicit syntax documents your intent.