kuntilanak
asked on
sql syntax
why is it giving me this error:
ERROR at line 1:
ORA-00933: SQL command not properly ended
ERROR at line 1:
ORA-00933: SQL command not properly ended
select itemname from x.item, (select itemno from x.sale, x.department where dname=deptname and deptfloor = 2) as t where item.itemno = t.itemno;
ASKER
why can't I use as?
ASKER
can you point out the error in my original query?
you can use "as", but the EXISTS is likely to give better performance.
how do you run the query? in pl/sql possibly?
then, you have to know that you cannot run SELECT like that inside pl/sql.
how do you run the query? in pl/sql possibly?
then, you have to know that you cannot run SELECT like that inside pl/sql.
ASKER
sql++
Is this what you are trying to do?
~bp
~bp
SELECT itemname
FROM x.item i,
x.sale s,
x.department d
WHERE s.dname = d.deptname
AND d.deptfloor = 2
AND i.itemno = s.itemno;
ok, but as pl/sql block, or simply the "SELECT" as such?
ASKER
your querying method seems a bit different with mine.. I never used select i itemno, I always use select itemno
you should use table aliases all the time, as it makes it 100% clear from which table the column is coming from.
when you have to read the query later, you don't have to look up the table column design to know, you can just read it from the query.
when you have to read the query later, you don't have to look up the table column design to know, you can just read it from the query.
ASKER
angelll I have no idea what a table aliases is? is it the as?
@kuntilanak,
I think, based upon the aliased able, that the statement shouldhave started
SELECT i.itemno
I.e., a period between the "i" and he "iemno".
I think, based upon the aliased able, that the statement shouldhave started
SELECT i.itemno
I.e., a period between the "i" and he "iemno".
ASKER
if you're referring to the as, yes that is my main problem.. never been successfull using as
select itemname from x.item, (select itemno from x.sale, x.department where dname=deptname and deptfloor = 2 as t) where item.itemno = t.itemno;
AngelIII's statement - I presume x is the schema name owning the tables "sale", "item" and "department" ?
kuntilanak - Can you confirm this?
kuntilanak - Can you confirm this?
ASKER
that is true
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
something like this ...
Open in new window