"not unique table/alias"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack Tanner

    #1

    "not unique table/alias"

    I have two complex subqueries that I need to join. I suspect this
    problem is due to using aliases instead of table names, but I don't
    know how to work around it (temporary tables?). Please help.

    SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
    JOIN t1 ON t2.col = t1.col;
    [color=blue][color=green][color=darkred]
    >>> Not unique table/alias: 't1'.[/color][/color][/color]

    SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
    WHERE t2.col = t1.col;
    [color=blue][color=green][color=darkred]
    >>> Works fine! (But this query is different, because it doesn't get[/color][/color][/color]
    the rows that are NULL in one of the tables.)

    Using MySQL 4.1.1. Thanks in advance for your help.
  • Siemel Naran

    #2
    Re: "not unique table/alias"

    "Jack Tanner" <ihok@hotmail.c om> wrote in message
    [color=blue]
    > I have two complex subqueries that I need to join. I suspect this
    > problem is due to using aliases instead of table names, but I don't
    > know how to work around it (temporary tables?). Please help.
    >
    > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
    > JOIN t1 ON t2.col = t1.col;
    >[color=green][color=darkred]
    > >>> Not unique table/alias: 't1'.[/color][/color]
    >
    > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
    > WHERE t2.col = t1.col;
    >[color=green][color=darkred]
    > >>> Works fine! (But this query is different, because it doesn't get[/color][/color]
    > the rows that are NULL in one of the tables.)
    >
    > Using MySQL 4.1.1. Thanks in advance for your help.[/color]

    Looks like a bug.


    Comment

    • Siemel Naran

      #3
      Re: &quot;not unique table/alias&quot;

      "Jack Tanner" <ihok@hotmail.c om> wrote in message
      [color=blue]
      > I have two complex subqueries that I need to join. I suspect this
      > problem is due to using aliases instead of table names, but I don't
      > know how to work around it (temporary tables?). Please help.
      >
      > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
      > JOIN t1 ON t2.col = t1.col;
      >[color=green][color=darkred]
      > >>> Not unique table/alias: 't1'.[/color][/color]
      >
      > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
      > WHERE t2.col = t1.col;
      >[color=green][color=darkred]
      > >>> Works fine! (But this query is different, because it doesn't get[/color][/color]
      > the rows that are NULL in one of the tables.)
      >
      > Using MySQL 4.1.1. Thanks in advance for your help.[/color]

      Looks like a bug.


      Comment

      • Jack Tanner

        #4
        Re: &quot;not unique table/alias&quot;

        "Siemel Naran" <SiemelNaran@RE MOVE.att.net> wrote in message news:<5TAnc.375 70$Ut1.1082414@ bgtnsc05-news.ops.worldn et.att.net>...[color=blue]
        > "Jack Tanner" <ihok@hotmail.c om> wrote in message
        >[color=green]
        > > I have two complex subqueries that I need to join. I suspect this
        > > problem is due to using aliases instead of table names, but I don't
        > > know how to work around it (temporary tables?). Please help.
        > >
        > > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
        > > JOIN t1 ON t2.col = t1.col;
        > >[color=darkred]
        > > >>> Not unique table/alias: 't1'.[/color]
        > >
        > > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
        > > WHERE t2.col = t1.col;
        > >[color=darkred]
        > > >>> Works fine! (But this query is different, because it doesn't get[/color]
        > > the rows that are NULL in one of the tables.)
        > >
        > > Using MySQL 4.1.1. Thanks in advance for your help.[/color]
        >
        > Looks like a bug.[/color]

        Could someone from @mysql.com confirm this? Should I be reporting on bugs.mysql.com?

        Comment

        • Jack Tanner

          #5
          Re: &quot;not unique table/alias&quot;

          "Siemel Naran" <SiemelNaran@RE MOVE.att.net> wrote in message news:<5TAnc.375 70$Ut1.1082414@ bgtnsc05-news.ops.worldn et.att.net>...[color=blue]
          > "Jack Tanner" <ihok@hotmail.c om> wrote in message
          >[color=green]
          > > I have two complex subqueries that I need to join. I suspect this
          > > problem is due to using aliases instead of table names, but I don't
          > > know how to work around it (temporary tables?). Please help.
          > >
          > > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
          > > JOIN t1 ON t2.col = t1.col;
          > >[color=darkred]
          > > >>> Not unique table/alias: 't1'.[/color]
          > >
          > > SELECT col FROM (subquery-1) AS t1, (subquery-2) AS t2
          > > WHERE t2.col = t1.col;
          > >[color=darkred]
          > > >>> Works fine! (But this query is different, because it doesn't get[/color]
          > > the rows that are NULL in one of the tables.)
          > >
          > > Using MySQL 4.1.1. Thanks in advance for your help.[/color]
          >
          > Looks like a bug.[/color]

          Could someone from @mysql.com confirm this? Should I be reporting on bugs.mysql.com?

          Comment

          • Aggro

            #6
            Re: &quot;not unique table/alias&quot;

            Jack Tanner wrote:
            [color=blue][color=green][color=darkred]
            >>>>Not unique table/alias: 't1'.[/color][/color][/color]

            I don't know if this helps you, but I have always done it differently.
            See the examples:

            mysql> select * from t1,t2 left join t1 on t1.id=t2.id;
            ERROR 1066: Not unique table/alias: 't1'

            mysql> select * from t1 left join t2 on t1.id=t2.id;
            +------+------+------+------+
            | id | name | id | name |
            +------+------+------+------+
            | 1 | car | 1 | cat |
            | 2 | cube | NULL | NULL |
            +------+------+------+------+
            2 rows in set (0.00 sec)

            # Or if you want to use aliases:
            mysql> select * from t1 as k1 left join t2 as k2 on k1.id=k2.id;

            I have version 3 of MySQL so can't try with subqueries. And I don't
            whether you are supposed to be able to do it the way you tried or not.

            Comment

            • Aggro

              #7
              Re: &quot;not unique table/alias&quot;

              Jack Tanner wrote:
              [color=blue][color=green][color=darkred]
              >>>>Not unique table/alias: 't1'.[/color][/color][/color]

              I don't know if this helps you, but I have always done it differently.
              See the examples:

              mysql> select * from t1,t2 left join t1 on t1.id=t2.id;
              ERROR 1066: Not unique table/alias: 't1'

              mysql> select * from t1 left join t2 on t1.id=t2.id;
              +------+------+------+------+
              | id | name | id | name |
              +------+------+------+------+
              | 1 | car | 1 | cat |
              | 2 | cube | NULL | NULL |
              +------+------+------+------+
              2 rows in set (0.00 sec)

              # Or if you want to use aliases:
              mysql> select * from t1 as k1 left join t2 as k2 on k1.id=k2.id;

              I have version 3 of MySQL so can't try with subqueries. And I don't
              whether you are supposed to be able to do it the way you tried or not.

              Comment

              Working...