pull data from a sql string RRS feed

  • Question

  • So the problem i am having is i have a string of data, address, and i need to pull just the city out to compare to another location

    example of Table

    Fname     lname       address

    John        Smith       731 Fondren, Houston, TX


    i need to pull houston to compare it to another table for location... dont know if i am explaining this correctly... if i can clear up my question just let me know... its a rather small amount of data... about 10 entries...


    i have tried SELECT CAST(SUBSTRING(@Address, CHARINDEX(',', @Address) + 1, 8) AS address)
    from employee
    where fname = 'john';
     but i could be doing something completely wrong ...


    now the 8 is just a place holder til i get it 2 work and can change it to where it will find the second ','


    i am a complete novice to everything sql

    • Edited by Kyle9856 Thursday, February 17, 2011 4:52 AM
    Thursday, February 17, 2011 4:33 AM


  • Kyle, if you are using Oracle 10g then this is not the right place you are seeking advice.

    Please check any Oracle forum.

    MCCA 2011
    • Proposed as answer by Naomi N Thursday, February 17, 2011 3:03 PM
    • Marked as answer by Kalman Toth Wednesday, February 23, 2011 9:43 AM
    Thursday, February 17, 2011 5:25 AM

All replies