showing mysql fields as NULL

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

    showing mysql fields as NULL

    i want to output the empty fields in one table to show up as NULL in my
    query. I tried using left join but couldn't get it to work. Here's my
    first try:
    SELECT * FROM info left join info on id=1
    query failed:1066: Not unique table/alias: 'info'


    Since left join usually uses two tables, I also tried using an alias,
    but I got the same error message.
    SELECT * FROM info as alias left join alias on id=1
    query failed:1066: Not unique table/alias: 'alias'

    What as missing ?


  • Gordon Burditt

    #2
    Re: showing mysql fields as NULL

    >i want to output the empty fields in one table to show up as NULL in my[color=blue]
    >query. I tried using left join but couldn't get it to work. Here's my
    >first try:
    >SELECT * FROM info left join info on id=1
    >query failed:1066: Not unique table/alias: 'info'
    >
    >
    >Since left join usually uses two tables, I also tried using an alias,
    >but I got the same error message.
    >SELECT * FROM info as alias left join alias on id=1
    >query failed:1066: Not unique table/alias: 'alias'
    >
    >What as missing ?[/color]

    Give the two instances of the table *DIFFERENT* aliases.

    SELECT * FROM info a LEFT JOIN info b ON a.parent = b.id WHERE b.id = 1;

    Gordon L. Burditt

    Comment

    Working...