jteixeira Posted December 20, 2006 Share Posted December 20, 2006 Hello,I have 1 table, 2 columns - desc and barcodeIn the barcode column I products CAP-..... and RES-....I want to make a condition if i select 1, list all products with CAP and 2, list all the products with RESMore or less this:variable->kif k=1 select all from infor where desc like 'CAP%'if k=2 select all from infor where desc like 'RES%' Link to comment Share on other sites More sharing options...
justsomeguy Posted December 20, 2006 Share Posted December 20, 2006 That's right, but instead of select all you need select *. Link to comment Share on other sites More sharing options...
jteixeira Posted December 21, 2006 Author Share Posted December 21, 2006 I put this:variable->kif k=1select * from inforwhere descricao like 'CAP%'if k=2select *from inforwhere descricao like 'RES%'and show me this -> Msg 102, Level 15, State 1, Line 1 Incorrect syntax near '>'. Link to comment Share on other sites More sharing options...
justsomeguy Posted December 21, 2006 Share Posted December 21, 2006 variable->kif k=1select * from inforwhere descricao like 'CAP%'if k=2select *from inforwhere descricao like 'RES%'Is that code you are running? I thought it was pseudo-code, to illustrate what you want to do. Is that actual code you are trying to run? What are you trying to run it on? What database are you using? Link to comment Share on other sites More sharing options...
jteixeira Posted December 22, 2006 Author Share Posted December 22, 2006 yes it is a pseudo-code but i don't know how to do to run sucessfull (i'am using sql server express)Database -> barcodeTable -> inforComuns -> descricao(description) and codbarras(barcode) Link to comment Share on other sites More sharing options...
justsomeguy Posted January 3, 2007 Share Posted January 3, 2007 You'll probably want to use something like PHP or ASP to run a different query based on the variable. if (k == 1) recordset.Open("SELECT * FROM infor WHERE descricao LIKE 'CAP%'");else recordset.Open("SELECT * FROM infor WHERE descricao LIKE 'RES%'"); Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now