Page 1 of 2 12 LastLast
Results 1 to 15 of 23

Thread: SQL Query

  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: SQL Query

    Hi

    Thought I'd get some ideas from the gurus here.

    Basically I am querying a table and generating a report with the returned data.
    Now, what I'm after is that e.g., one of the returned columns gives rows containing string:
    1.1.1.1
    1.1.1.2
    1.1.1.3
    etc
    And 1.1.1.1 means A
    1.1.1.2 means B
    1.1.1.3 means C
    etc

    Is there any way that I can get output so that I see 1.1.1.1 A, 1.1.1.2 B, 1.1.1.3 C.....and so on?

    Appreciate your advice.

    Regards

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    What is the expected/desired results for rows 27 - 10000?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Aug 2008
    Posts
    464

    SQL Query

    Hi

    Thought I'd get some ideas from the gurus here.

    Basically I am querying a table and generating a report with the returned data.
    Now, what I'm after is that e.g., one of the returned columns gives rows containing string:
    1.1.1.1
    1.1.1.2
    1.1.1.3
    etc
    And 1.1.1.1 means A
    1.1.1.2 means B
    1.1.1.3 means C
    etc

    Is there any way that I can get output so that I see 1.1.1.1 A, 1.1.1.2 B, 1.1.1.3 C.....and so on?

    Appreciate your advice.

    Regards

  4. #4
    Join Date
    Aug 2008
    Posts
    464
    Thanks for the sarcasm.

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    That's no sarcasm, your explanation is lacking essential information.

    If 1.1.1.1 "equals" A then 1.1.1.26 will "equal" Z, so what should happen after that?

    And what is 3.4.5.6, or 100.12.42.12445

  6. #6
    Join Date
    Aug 2008
    Posts
    464
    Sorry, I didn't look so far into what could have been interpreted by my explanation....Probably used wrong example.

    Basically if you don't read so much into the explanation....by A, B, C, I mean 3 words like ABC, QWE, RTY.

    Hope my question is more clearer.

  7. #7
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Hope my question is more clearer.
    Your response is less clear.

    What is algorithm for transforming input to "desired" results?

    Post DDL for tables.
    Post DML for test data.

    Post expected/desired results.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by shajju
    by A, B, C, I mean 3 words like ABC, QWE, RTY.
    okay, i can see how ABC maps to A, but how do you get QWE to map to B?

    and how does 1.1.1.1 map to ABC ????

    where are these mappings stored, in some other table or hardcoded in your application logic?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Aug 2008
    Posts
    464
    OK,, I'll try and explain using the words I want to use.

    The words are BSC1, BSC2, BSC3. They do not exist in the same table(A) but do in a different table(B).

    I want to see these words in the output alongwith the strings (that exist in table (A)).

    So I was hoping to somehow write a query which showed me BSC1, 2 and 3 alongwith the strings 1.1.1.1, 1.1.1.2, 1.1.13. OR query 2 tables to map the BSCs to the strings.

    Regards

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    that would be a simple join between tables A and B

    and why couldn't you have "used the words you wanted to use" in the first post?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >They do not exist in the same table(A) but do in a different table(B).
    Why did it take 4 posts to inform us a second table was involved?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  12. #12
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    I can only repeat anacedent's post:

    Post DDL for tables.
    Post DML for test data.
    Post expected/desired results.

  13. #13
    Join Date
    Aug 2008
    Posts
    464
    I myself didn't think of the second table at first...On second thought, there isn't another table to get the BSCs from.

    And even if there was one, what if I don't want to use a second table...just for argument's sake.

    Is there any way I can say in SQL that for this col B in the table, assign the word BSC1 next to the values that ='1.1.1.1' and assign the word BSC2 next to the values='1.1.1.2'....and so on....

  14. #14
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by shajju
    Is there any way I can say in SQL that ...
    yes, there are two ways, but bofadem are far more clumsy than just using a second table for that purpose
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  15. #15
    Join Date
    Aug 2008
    Posts
    464
    Well you see, there isn't really a second table that contains exactly what I'd like to see next to e.g., 1.1.1.1 like I'd like to see BSC(1) RX/TX. So....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •