Simply getting a list of all values (multiple rows) inside a column...

Discussion in 'MySQL' started by sabin, Jan 22, 2012.

  1. #1
    Hello !

    I'm sorry to say I am a big newbie with mysql stuff, despite having to use it for years, please, could I humbly ask for a bit of help ? :)

    To give you the context,
    - in my
    database_name,
    - inside
    database_table
    - there is a column of data called
    UserIP
    - another column called
    UserID
    - and another column called
    EventNumber

    There are several rows (lines, just in case I may cause accidentally a misunderstanding !) with various eventIDs, one after the other, and the userIP will vary regularly.

    What I want is to be able to "print" (or obtain within phpmyadmin, call it whowever you like) every userIP value for a precise userID.

    I'm certain this is quite easily doable - except that I absolutely have no idea how to proceed, I'm sorry :(

    Please, would you know how to do that ?

    Thank you VERY MUCH if you can help me, I'll be grateful ! :)
     
    sabin, Jan 22, 2012 IP
  2. dwirch

    dwirch Well-Known Member

    Messages:
    239
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #2
    Get all records with a specific userID:

    Select * from MyTable where userid=x

    Get all UserIPs with a specific UserID:

    Select UserIP from MyTable where userID=x


    This what you are looking for?
     
    dwirch, Jan 22, 2012 IP
    sabin likes this.
  3. sabin

    sabin Well-Known Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #3
    (EDITED : please move to the post below, scroll down, I improved one step further, the present post is obsolete.)
     
    Last edited: Jan 22, 2012
    sabin, Jan 22, 2012 IP
  4. sabin

    sabin Well-Known Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Ah, I'm almost there ! (been trying all variations around the structure proposed by phpmyadmin and using as root what you suggested, Dwirch)

    SELECT UserIP
    FROM `database_name`.`database_table`
    WHERE (
    `userID` LIKE '%the_user_name_whose_IPs_I_need%'
    )
    LIMIT 0 , 30
    Code (markup):
    The last problem, hopefully, is that this generates a long list from which I'd have to copy and paste each of them separately, one IP per line.

    Would you know if there's a solution to this ?
     
    sabin, Jan 22, 2012 IP
  5. dwirch

    dwirch Well-Known Member

    Messages:
    239
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    135
    #5
    Glad you got the names figured out. Experimentation is good, yes?

    So are you looking to export them to a file? A spreadsheet?

    I can't speak for phpAdmin, as am neither a phpAdmin user or a php developer at all. I *do* use MySQL workbench, and it has the ability to export to a spreadsheet or CSV file from right within the interface.
     
    dwirch, Jan 22, 2012 IP
  6. sabin

    sabin Well-Known Member

    Messages:
    114
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #6
    Nothing beats experimentation, yep. But having initial pointers saves countless hours :)

    Any export format would do, once it's in a line or separated by characters, it's ready to fall prey to my notepad++ and become whatever I need...
     
    sabin, Jan 22, 2012 IP