CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Simple SQL

  1. #1
    Join Date
    Apr 2000
    Location
    Germany
    Posts
    122

    Simple SQL

    Something basic :
    I have two tables tbl1 and tbl2 in a mysql database.

    The first table has three records X, Y, Z
    and the the second table has two records A and B

    They have no common fields ( foreign keys )

    With an SQL statement I'd like to generate a list of six records looking like this :
    • X A
    • X B
    • Y A
    • Y B
    • Z A
    • Z B

    (Sequence is not important)
    There is some basic function to do this which I can't recall at the moment.
    I have a suspicion that it is only possible in Oracle with the sub-select
    statements ( = select f1 from tblx where f2 = (select f3 from tbly) ; )
    Can you help me on this?

  2. #2
    Join Date
    Jun 2001
    Location
    Mi
    Posts
    1,249
    Not really possible ... You can either of the sets with a Left or Right Outer Join ...

  3. #3
    Join Date
    Apr 2000
    Location
    Germany
    Posts
    122

    How Embarassing

    found it,
    to show a list of 6 elements from a table of 3 and a table of 2 one writes :

    select * from tbl1, tbl2;

    that outer/inner join stuff I'll try too.

  4. #4
    Join Date
    Jan 2003
    Location
    7,107 Islands
    Posts
    2,487

    Lightbulb

    Another join term for this is called CROSS JOIN

    SELECT * FROM T1 CROSS JOIN T2
    Busy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured