F
F
fraurig2018-02-05 11:23:06
Oracle
fraurig, 2018-02-05 11:23:06

Subqueries. What to write after the second select?

Hello!

Tell me what to write after the second select'a?

Example, there are two tables (T1 - orders table, T2 - geographical points table).

Expected result: display of all orders where the name of the city (acceptance) begins with "KA".

select  *
from  T1
where t1.DEST_LOCATION_GID IN (select t2.LOCATION_GID
from T2
where t2.location_NAME like 'КА%')


If you substitute * or 1 in the second select, then the request does not work. Why is this happening?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2018-02-05
@res2001

Do it via join, you don't need in here:

select  t1.* from  T1 as t1
left join T2 as t2 on t2.location_NAME like 'КА%' and t2.LOCATION_GID=t1.DEST_LOCATION_GID

M
Max Payne, 2018-02-05
@YardalGedal

Because the second query should only return one column, otherwise how would one t1.DEST_LOCATION_GID column compare to more than one?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question