select rows based on code

  • hbtkp (4/11/2012)


    it doesnt matter , how do i get those value in select stm

    It does matter.

    Going down the same road as with of the other OPs. I think it's time to walk away.

  • hbtkp (4/11/2012)


    it doesnt matter , how do i get those value in select stm

    In that case, the answer you are looking for is here.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • i havent done anything for this ,trying to use case but doesnt work

  • hbtkp (4/11/2012)


    i havent done anything for this ,trying to use case but doesnt work

    well until you provide concrete details we've asked for for 3 forum pages so far, none of the volunteers can help you.

    We do wish you all the best in fixing your issue yourself!

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • ok i need to match @% in my query ,how to do that

    if i do using like '@%' its not working

  • hbtkp (4/11/2012)


    ok i need to match @% in my query ,how to do that

    if i do using like '@%' its not working

    There's no such thing as just [@] in SQL.

    @ begins the name of a variable, and it must be two characters minimum including the @ sign.

    @_ would be allowed, for example, or @a.

    DECLARE @Var varchar(10)

    SET @Var = 'pen' + '%' --note i'm adding the % here

    SELECT * From MyTable Where SomeColumn like @Var

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • will this work '@_%'

  • @ is not in sql,it just constant in my sql

  • ok, then if you were searching email addresses for example, and you want to find items with teh @ symbol,then it's like this:

    DECLARE @Var varchar(10)

    SET @Var ='%' + '@' + '%' --note i'm adding the % here

    SELECT * From MyTable Where SomeColumn like @Var

    or without a variable:

    SELECT * From MyTable Where SomeColumn like '%@%'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • How does the database know that item3 holds the value "pen, pencil"?...Is there a table where you have specified that item3 refers to "pen, pencil"?....

    If there is then you need to do a join of the two tables(the one you have mentioned and the other table where item3 has the values "pen, pencil") to get code and the value of item3("pen, pencil").

    SQL tables hold the data you(users) store and when you query these tables, SQL returns only the same data which you have provided it with. It doesn't have any form of artificial intelligence to know what item3 is without you telling it what it is.

    Vinu Vijayan

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

Viewing 10 posts - 16 through 24 (of 24 total)

You must be logged in to reply to this topic. Login to reply