gokhul Posted June 4, 2009 Share Posted June 4, 2009 Hello, Can anyone tell me how to get the result from 3 columns that have the same value. I have 5 columns namely patient age diag1 diag2 diag3 1 20 75 20 100 2 30 89 100 67 3 40 100 89 89 I need to get the total details as result that has a value 100 in either of the three columns(diag1,diag2,diag3). I am using the following code.... select * from patient where diag1 or diag2 or diag3=100; is that correct? Please help me. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 SELECT * FROM patient WHERE 100 IN (diag1, diag2, diag3); That should work. Alternatively, you can do - SELECT * FROM patient WHERE diag1 = 100 OR diag2 = 100 OR diag3 = 100; Quote Link to comment Share on other sites More sharing options...
gokhul Posted June 4, 2009 Author Share Posted June 4, 2009 Hey ken...how are you? it was you..who helped me last time. nice meeting you once again. that code is not working. it is either giving the record of patient 3 or it is giving all the records in the table. Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted June 4, 2009 Share Posted June 4, 2009 It should work. Show me what you have. Quote Link to comment Share on other sites More sharing options...
gokhul Posted June 4, 2009 Author Share Posted June 4, 2009 Its working. thanks a lot. Once again...you helped me a lot. Thanks once again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.