Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to select All of removed tyre from my Vehicle table and also want to select all Newissue Tyre from table Vehicle wich are not have removed this is table.

Detail_ID| Nessesity| VehicleNo| Activity | MetreReading| SerialNo| WarrantyUPTO|
        5	Tyre	  CG04JC7882| NEW ISSUE| 1000	     |  MRF-1  | 31/10/2020
        6	Tyre	  CG04JC7882| NEW ISSUE| 1000	     |  MRF-2  | 31/10/2020
        7	Tyre	  CG04JC7882| NEW ISSUE| 1000	     |  MRF-3  | 31/10/2020
        8	Tyre	  CG04JC7882| NEW ISSUE| 1000	     |  MRF-4  | 31/10/2020
        9	Tyre	  CG04JC7882| REMOVE   | 2000	     |  MRF-4  | 31/10/2020
        10	Tyre	  CG04JC7882| NEW ISSUE| 2000	     |  MRF-5  | 31/10/2020						


What I have tried:

i am using this statement 

<pre>Select SerialNo From necessitycompdetail where VehicleNo='CG04JC7882' and Activity='REMOVE' or (Select SerialNo From necessitycompdetail where Activity!='NEW ISSUE')



 
Select SerialNo From necessitycompdetail where VehicleNo='CG04JC7882' and Activity!='REMOVE' or (Select SerialNo From necessitycompdetail where Activity='NEW ISSUE') 


First One is working Fine but second one is giving error
Error Code: 1242. Subquery returns more than 1 row

Please Help me
Posted
Updated 21-Aug-20 2:27am
v5
Comments
CHill60 21-Aug-20 8:30am    
My bad - I tried to tidy up the question and some weird things happened. I've rolled back to your original. My apologies
Asif 7969814 21-Aug-20 8:36am    
it's Ok

1 solution

OR is a logical (or boolean) operation - it expects a condition on either side.
So this would work:
SQL
SELECT SerialNo FROM necessitycompdetail 
WHERE VehicleNo = 'CG04JC7882' 
  AND (Activity = 'REMOVE' OR  Activity = 'NEW ISSUE')

But I'm not sure exactly what you are trying to do: are you trying to get tyres which have not been removed - perhaps a list of what you want to get from your sample data would help?
 
Share this answer
 
Comments
CHill60 21-Aug-20 8:30am    
Also see my comment - I honestly did not change the question 5 times!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900