Jump to content

Sql Query A Query


Recommended Posts

Posted

[background=transparent] [/background][color=#00008B][background=transparent]WHERE[/background][/color][background=transparent] [/background][background=transparent]([/background][background=transparent]FIELD2 [/background][color=#00008B][background=transparent]LIKE[/background][/color][background=transparent] [/background][color=#800000][background=transparent]'%value21'[/background][/color][background=transparent] [/background][color=#00008B][background=transparent]OR[/background][/color][background=transparent]
FIELD2 [/background][color=#00008B][background=transparent]LIKE[/background][/color][background=transparent] [/background][color=#800000][background=transparent]'%value22'[/background][/color][background=transparent] [/background][color=#00008B][background=transparent]OR[/background][/color][background=transparent]
FIELD2 [/background][color=#00008B][background=transparent]LIKE[/background][/color][background=transparent] [/background][color=#800000][background=transparent]'%value23'[/background][/color][background=transparent] [/background][background=transparent]...)[/background]

[url="http://stackoverflow.com/questions/3936258/how-to-write-a-sql-statement-to-use-like-for-9-different-values"]http://stackoverflow.com/questions/3936258/how-to-write-a-sql-statement-to-use-like-for-9-different-values[/url]

Posted

What is this man... ee chaduvukuney pillollu unnareyyyy andarini teesukelli oka graham pai veyali man [img]http://25.media.tumblr.com/4edf07f444d1c672a842a2fca4194e82/tumblr_mqiz99Clrl1spvnemo1_250.gif[/img]

Posted

let me tell u my thinking

i am plannig to pass the value as param

like

select * from emp where name like (var)

var = '%xxx%','

and i will keep adding as and when i require

Posted

[quote name='GatisKandis' timestamp='1381412081' post='1304387432']
chandra akka copy [img]http://lh3.ggpht.com/--o7mXz3u-j4/T9VVBGzBJAI/AAAAAAAAGo0/kmj8a1-XW2g/s150/PK-1.gif[/img]
[/quote]
copy kadhu paine chepanu :police:[size=4] [/size]

Posted

pass the values in these variables might be input to proc trigger or whatever do your stuff
declare @var1 varchar(20),V VARHCAR(20)

set @var1 ='CJ',@var2 = 'CD'

select * from emp where emp_name like LIKE %'+@var1+'% OR nameLIKE %'+@var2+'% OR name LIKE %'+var1+'%
[quote name='cherlapalli_jailer' timestamp='1381412047' post='1304387429']
kaani ...say for example. i want to pass the value as param ....i need to modify my SQL every time kada
[/quote]

Posted

joke vesa :police:
[quote name='littlemoon' timestamp='1381412276' post='1304387445']
copy kadhu paine chepanu :police:
[/quote]

Posted

office ki ready avtunna... tarvata vachi neeku solution istaa... but what do u mean by I will be adding more when I require.. Please elaborate man?

Posted

ok thank you every one....let me think of it ...

can we do like this(preformance wise kooda cheppandi)


here thing is value in DB will be
asfasfSAMUY
asfasfTARA
asfasfDIVa
so i want to skip asfasf this and select all three records

select * from emp where name in ( substring(var,6) ,substring(val2,6) ) etc

Posted

[quote name='GatisKandis' timestamp='1381412301' post='1304387446']
pass the values in these variables might be input to proc trigger or whatever do your stuff
declare @var1 varchar(20),V VARHCAR(20)

set @var1 ='CJ',@var2 = 'CD'

select * from emp where emp_name like LIKE %'+@var1+'% OR nameLIKE %'+@var2+'% OR name LIKE %'+var1+'%
[/quote]
so if want tot add another then i have to modify SQL? right?

Posted

[quote name='loveindia' timestamp='1381412391' post='1304387454']
office ki ready avtunna... tarvata vachi neeku solution istaa... but what do u mean by I will be adding more when I require.. Please elaborate man?
[/quote]


means for exmple

in (var) anukundamu

var for today it will be 'SAMYU'
t'row tara can join so
i will reconstruct var = 'SAMYU','DIVA')
so on...

Posted

[quote name='cherlapalli_jailer' timestamp='1381412527' post='1304387468']


means for exmple

in (var) anukundamu

var for today it will be 'SAMYU'
t'row tara can join so
i will reconstruct var = 'SAMYU','DIVA')
so on...
[/quote]

Basically to give you an idea, there are two ways to do this.

1) Dynamic SQL -- Cos you don't know how many number of inputs you have.

2) Put all the inputs through a loop and pass to the Query and save the results into a temp table and retrieve it at the end.

These both I can think just out of my head right now.

Posted

[quote name='GatisKandis' timestamp='1381412366' post='1304387452']
joke vesa :police:
[/quote] ok :)
[quote name='cherlapalli_jailer' timestamp='1381412411' post='1304387458']
ok thank you every one....let me think of it ...

can we do like this(preformance wise kooda cheppandi)


here thing is value in DB will be
asfasfSAMUY
asfasfTARA
asfasfDIVa
so i want to skip asfasf this and select all three records

select * from emp where name in ( substring(var,6) ,substring(val2,6) ) etc
[/quote] ante last variables change avthu untaya?

Posted

[quote name='loveindia' timestamp='1381413050' post='1304387502']

Basically to give you an idea, there are two ways to do this.

1) Dynamic SQL -- Cos you don't know how many number of inputs you have.

2) Put all the inputs through a loop and pass to the Query and save the results into a temp table and retrieve it at the end.

These both I can think just out of my head right now.
[/quote]
both looks good

2nd one more implementable

Thanks a lot .. let me re design my stuff in those lines

Posted

thank you @gatis,@littleMoon ,@mandumarbalam and @loveindia

Posted

thanks to @
[b] [url="http://www.andhrafriends.com/user/19251-hellyeah/"]HellYeah[/url][/b]


[b] [url="http://www.andhrafriends.com/user/36707-billgatesof21stcentury/"]BillGatesOf21stCentury[/url][/b]


ROBO

×
×
  • Create New...