Friday, March 23, 2012

Query for tables.

how can i fetch somw rows having same field value?

my table is like:

name id

x 1

y 2

z 2

w 5

so how can i get rows y and z for id=id ?

This is a Transact-SQL question and should be asked over there... To save you some time though:

select name, id from [table] a, [table] b
where a.id = b.id and a.name <> b.name

Will return:

x 2
y 2|||

thx sir...

lemme modify for others...

select t1.* from table1 t1,table1 t2 where t1.id=t2.id and t1.name<>t2.name

No comments:

Post a Comment