oracle - Trouble With Basic Query Searching -


not sure if right place ask have question beginner sql.

i have table dept , emp include:

sql> desc dept;  name                                      null?    type  ----------------------------------------- -------- ----------------------   deptno                                             number(2)  dname                                              varchar2(14)  loc                                       not null varchar2(13)  sql> desc emp;  name                                      null?    type  ----------------------------------------- -------- ----------------------   empno                                              number(4)  ename                                              varchar2(10)  job                                                varchar2(9)  mgr                                                number(4)  hiredate                                           date  sal                                                number(7,2)  comm                                               number(7,2)  deptno                                             number(2) 

i need search jobs in department 30 , include location of department 30.

what im trying this:

sql> select emp.job, dept.deptno, dept.loc   2  emp, dept   3  emp.deptno = dept.deptno   4  deptno = '30'; deptno = '30' * error @ line 4: ora-00933: sql command not ended 

but can see not working , have tried different variations still no luck. on right track? how solve this?

it sounds want this. when have multiple conditions in where clause, specify where once , combine them and or or conditions.

select emp.job, dept.deptno, dept.loc  emp, dept emp.deptno = dept.deptno   , dept.deptno = 30; 

unless there reason need use old join syntax, ought start sql 99 syntax. makes easier move between databases, makes queries easier read separating join , filter conditions, , makes life easier when start working on outer joins.

select emp.job, dept.deptno, dept.loc  emp        join dept         on( emp.deptno = dept.deptno ) dept.deptno = 30; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -