sql - mysql - fastest way to find rows having common field -


consider table 2 colums, col1 , col2.

i find fastest way compute rows having col2 equal col2 column of row having col1 equal given value.

for example, consider case want find names of people having same surname of person name 'john'

select t.* table t join table t2 on t2.col2 = t.col2 t2.col1 = 'some value' 

you need indexes on both columns performance.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -