Skip to main content
improved formatting
Link
Mat
  • 10.2k
  • 4
  • 43
  • 40

how to match Matching two rows in a single table whose some of theif two specific keys have different values are integer and some of them are in character

iI have a table called ''settings''settings in that therethere are two columns and data like this

settings valuefollowing.


depots 12 projectid 156 client icici bank clientvisits 2 DBname icicibank progress true displayvisits 2 visitsskipped 0

settings           value
-------            ------
depots             12
projectid          156
client             icici bank
clientvisits       2
DBname             icicibank
progress           true
displayvisits      2
visitsskipped      0

hereHere , the values of rows 'clientvisits'clientvisits and 'displayvisits'displayvisits should be same always. iI want a query which display the only these two fields along with values if theretheir values are differntdifferent. that That means if clientvisits=2 and displayvisits=4clientvisits=2 and displayvisits=4 then it should throw an error  (iI mean it should display the output along with values).

iI tried by using self join like this but it is not working

select * from settings TS,settings TS1 where TS.settings=TS1.settings and CONVERT(integer,ts.value)=1

select * from settings TS,settings TS1 where TS.settings=TS1.settings and ts.setting like 'visitstodisplay'=1

select * from settings TS,settings TS1
where TS.settings=TS1.settings and CONVERT(integer,ts.value)=1

select * from settings TS,settings TS1
where TS.settings=TS1.settings and ts.setting like 'visitstodisplay'=1 

also iAlso, I tried to do some thing else but iI didn't get. pleasePlease let me know how to do ASAPit.

i have a table called ''settings'' in that there are two columns and data like this

settings value


depots 12 projectid 156 client icici bank clientvisits 2 DBname icicibank progress true displayvisits 2 visitsskipped 0

here , the values of rows 'clientvisits' and 'displayvisits' should be same always. i want a query which display the only these two fields along with values if there values are differnt. that means if clientvisits=2 and displayvisits=4 then it should throw an error(i mean it should display the output along with values)

i tried by using self join like this but it is not working

select * from settings TS,settings TS1 where TS.settings=TS1.settings and CONVERT(integer,ts.value)=1

select * from settings TS,settings TS1 where TS.settings=TS1.settings and ts.setting like 'visitstodisplay'=1

also i tried to do some thing else but i didn't get please let me know how to do ASAP.

I have a table called settings in that there are two columns and data like following.

settings           value
-------            ------
depots             12
projectid          156
client             icici bank
clientvisits       2
DBname             icicibank
progress           true
displayvisits      2
visitsskipped      0

Here , the values of rows clientvisits and displayvisits should be same always. I want a query which display the only these two fields along with values if their values are different. That means if clientvisits=2 and displayvisits=4 then it should throw an error  (I mean it should display the output along with values).

I tried by using self join like this but it is not working.

select * from settings TS,settings TS1
where TS.settings=TS1.settings and CONVERT(integer,ts.value)=1

select * from settings TS,settings TS1
where TS.settings=TS1.settings and ts.setting like 'visitstodisplay'=1 

Also, I tried to do some thing else but I didn't get. Please let me know how to do it.

Source Link
user19858
  • 3
  • 1
  • 1
  • 2

how to match two rows in a single table whose some of the values are integer and some of them are in character

i have a table called ''settings'' in that there are two columns and data like this

settings value


depots 12 projectid 156 client icici bank clientvisits 2 DBname icicibank progress true displayvisits 2 visitsskipped 0

here , the values of rows 'clientvisits' and 'displayvisits' should be same always. i want a query which display the only these two fields along with values if there values are differnt. that means if clientvisits=2 and displayvisits=4 then it should throw an error(i mean it should display the output along with values)

i tried by using self join like this but it is not working

select * from settings TS,settings TS1 where TS.settings=TS1.settings and CONVERT(integer,ts.value)=1

select * from settings TS,settings TS1 where TS.settings=TS1.settings and ts.setting like 'visitstodisplay'=1

also i tried to do some thing else but i didn't get please let me know how to do ASAP.