Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [SQL]Pobranie elementu i elementów podobnych
Randallmaster
post
Post #1





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

Ostrzeżenie: (0%)
-----


Witam potrzebuje napisać zapytanie które odnajdzie wiersze oraz wiersze które są podobne do szukanego wiersza. Niestety nie wiem dokładnie jak napisać zapytanie:

id | name | symbol

1 | test | T1
2 | test2 | T2
3 | tesa | Ta
4 | inne | T1pokaz
5 | inne2 | T2pokaz

Kod
select * from tabela where name like ('%test%') and symbol like (select symbol from tabela where name like ('%test%') + '%')


docelowo powinno pokazać:

id | name | symbol

1 | test | T1
4 | inne | T1pokaz
2 | test2 | T2
5 | inne2 | T2pokaz

Jak napisać takie zapytanie ?

Ten post edytował Randallmaster 7.09.2015, 14:28:30
Go to the top of the page
+Quote Post
trueblue
post
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Przetestuj:
  1. SELECT s2.*
  2. FROM symbol AS s, symbol AS s2
  3. WHERE s.name LIKE ('%test%') AND s2.symbol LIKE (CONCAT(s.symbol,'%'))
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 15:08