Jump to content

If Condition


jteixeira

Recommended Posts

I have this Query ---->Select Infofin_prod.maquinaid,nicname,Infofin_prod.idprod,NomeProd,StockFrom Infofin_prod INNER JOIN Maquina on maquina.maquinaid=Infofin_prod.maquinaid INNER JOIN Stockss on stockss.maquinaid=Infofin_prod.maquinaid INNER JOIN Produtos on produtos.idprod=Infofin_prod.idprodGroup by Infofin_prod.maquinaid,nicname,Infofin_prod.idprod,NomeProd,StockOrder by StockI Want print a message if the Stock = 0, but i don't know i do it with a if condition :)

Link to comment
Share on other sites

if(select stock from Stockss Where stock=0)=0Begin Print 'erro'EndErro ---> Msg 512, Level 16, State 1, Line 1Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

Link to comment
Share on other sites

this part (select stock from Stockss Where stock=0) potentially can have more than 1 record so the you cannot compare it to asingle value.You are better off tryign to handle this in your server side code. You can loop through the returned records in SQL but it is messy and confusing.Just return the query and process the records with PHP or something.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...