P
P
Peter2018-05-31 18:22:20
PostgreSQL
Peter, 2018-05-31 18:22:20

How to find records in pgsql?

I have two tables:
player

id  | login
------+---------
 157 |   Ivan
 158 |   Bob
 159 |   Lylssy
 160 |   Wylsy

and someGame
id   |  game  | players
------+---------+---------
   1    |    gta   | [157, 159]  
   2    |    rpx   | [157]  
   3    |    xxx   | [159, 157, 158]  
   4    |    zzz   | [158, 159, 160]  
   5    |    yyy   | [158, 160]

How can I find the game(s) a player is playing in, knowing only part of the player's login (eg 'yls')?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick V, 2018-05-31
@volkov_p_v

select sg.game
from somegame sg
where sg.players @> (select array(
    select p.id
    from player p
    where lower(p.login) like lower('%yls%')
))

D
Dimonchik, 2018-05-31
@dimonchik2013

https://www.postgresql.org/docs/8.3/static/function...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question