Alias doesn't seem to work for DELETEs

jamietjamiet Posts: 11
edited January 31, 2007 10:05AM in SQL Prompt Previous Versions
Hi,

When I type the period at the end of this code snippet

"SELECT * FROM mytable t WHERE t."

then I am presented with the candidate list showing all columns in mytable. All good.

When I type:
"DELETE FROM mytable t WHERE t."

then I do NOT get the candidate list with just my columns. In fact it shows jsut about everything EXCEPT my column-list.

This seems wrong to me. Anyone agree?

-Jamie

Comments

  • Ignore this.... using aliases for DELETE isn't valid syntax!

    Sorry :oops:


    [Shame you can't delete posts on here :) ]
  • Hi,

    You can actually use aliases in DELETE (and UPDATE) statements, but you have to specify them in the FROM clause.

    E.g.

    DELETE FROM t
    FROM mytable t
    WHERE t.

    This would do what you want it to. Obviously the FROM clause is a bit superfluous when you specify only 1 table.

    Regards,

    Tilman
  • Thanks Tilman.

    So then, if that is true, my question in the first post of this thread is valid, is it not?
  • Hi, jamiet.

    If you use the syntax that Tilman showed, then the candidate list should be showing up after you type the alias. If it doesn't show up for you, then I would guess you've come across a bug, as it shows up for me. However, as you said, the syntax you originally used was incorrect, so it's not really surprising that SQL Prompt wasn't able to show the candidate list, in that case.

    Also, just as an FYI, you can also leave off the first FROM word. e.g.
    DELETE t
    FROM mytable t
    WHERE t.
    
    -Jesse
  • What he said :)

    Regards,

    Tilman
  • Thanks guys!!!
Sign In or Register to comment.