Search code examples
sqlsql-search

SQL Search query Result


SQL select attract but query I want to give the results as follows.

Select * from table where ???? Result

enter image description here


Solution

  • If I understood what you want .... this is how i would do it

    if object_id('tempdb..#Temp') is not null drop table #Temp
    create table #Temp (FirmName nvarchar(50))
    
    insert into #Temp (FirmName) 
    values ('Emlak 17'),
       ('Sanane Emlak'),
       ('GE Emlak => Result'),
       ('45 Emlak'),
       ('Emlak 3Z'),
       ('Burak Emlak')
    
    select * from #Temp
        where Len(LEFT(FirmName, charindex(' ',FirmName, 0))) = 2
           or LEN(RIGHT(FirmName,LEN(FirmName)-CHARINDEX(' ',FirmName))) = 2
    

    Just copy paste it and give it a go ... let me know if that worked for you and please man, read the part "How to ask a question"