Alias doesn't seem to work for DELETEs
jamiet
Posts: 11
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
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
Sorry :oops:
[Shame you can't delete posts on here ]
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
So then, if that is true, my question in the first post of this thread is valid, is it not?
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.
Regards,
Tilman