need query

This is a discussion on need query within the Microsoft SQL Server forums in category; i want to check whether a value exists in a table's row with some condition. actually the value may exists any of the column's value. is it possible with exists??? i tried the following query SELECT '9912' FROM table1 AS T1 WHERE EXISTS (SELECT * FROM table1 AS T2 WHERE T1.val2 ='HR1203' AND T2.val2 = T1.val2); but it is not correct... plese need a help........

Go Back   Database Forum > Microsoft SQL Server

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-07-2008, 03:22 AM
Red face need query

i want to check whether a value exists in a table's row with some condition.
actually the value may exists any of the column's value. is it possible with exists???
i tried the following query
SELECT '9912'
FROM table1 AS T1 WHERE EXISTS
(SELECT * FROM table1 AS T2
WHERE T1.val2 ='HR1203' AND
T2.val2 = T1.val2);
but it is not correct... plese need a help.....
Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 01:51 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.