Tristate
Tristate

Reputation: 1821

How to select row where one value also contains in another table

Let Say Table A

Name Age
Jon 23
Lili 43

Let Say Table B

Name Car
jon bmw
maya mercedes

I need exact 1 row of Table A where name also contains in Table B. Names in B are all lowercase.

What I tried:

select lower(name) from tableA intesects select lower(name) from tableB LIMIT 1;

But this gave me only name value not entire row (name, age)

For Jon I need as result.

| Jon | 23 |

because Jon is also contained in tableB as lowerCase.

Upvotes: 0

Views: 31

Answers (1)

user330315
user330315

Reputation:

Use an EXISTS condition:

select a.*
from tablea a
where exists (select * 
              from tableb b
              where lower(a.name) = lower(b.name));
 

Upvotes: 2

Related Questions