December 17, 2008 at 10:44 pm
Hi all,
I have a table Indus with 3 column serial,qh11,qh21
create table Indus(serial int,qh11 varchar(255),qh21 varchar(255))
serial qh11 qh21
1 234567890 45890
2 134567890 1345
3 2345679 49
4 23 35
5 234567890 2345
6 123456780 8
7 6
8 234567890 3458
I want to find the character or number which are present in qh21 must be in qh11. The number or character which r not in qh11 but present in qh21 should give as error like serial no 4 the number 5 in qh21 is not present in qh11.similarly serial no 7 the number 6 in qh21 is not present in qh11.
December 17, 2008 at 11:13 pm
Well your question is not clear but try this
This query will return rows where qh21 is "present" in qh11. Ex:- value 1345 in qh21 column is present in 134567890 in qh11 column.
select * from Indus WHERE qh11 like '%' + qh21 + '%'.
"Keep Trying"
December 17, 2008 at 11:39 pm
My output should look like the below
serial qh11 qh21
4 23 35
7 6
serial no 4 ,qh21 has the number 3 and 5 and 5 is not present in qh11.Similarly serial no 7 qh21 has the number 6 which is not present in qh11. I want to check each number in
qh21 must be present in qh11.
serial qh11 qh21
1 234567890 45890
2 134567890 1345
3 2345679 49
5 234567890 2345
6 123456780 8
8 234567890 3458
In serial no 1, qh11 has the value 234567890 and qh21 has 45890 . 4 is present in qh11,5 is present in qh11,8 is present in qh11,9 is present in qh11 and 0 is present in qh11.each number in qh21 is present in qh11. similarly with serial no 2,3,5,6 and 8,but is not the same in serial no 4 and 7.I hope u got my question
December 18, 2008 at 10:40 pm
Hi
query to find matching records
select * from indus WHERE qh11 like '%' + qh21 + '%'
query to find non matching records
select * from indus WHERE qh11 not like '%' + qh21 + '%'
Please dont post the question repeatedly.
"Keep Trying"
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply