SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem regarding output of MySQL multiple rows

    HI friends..I have a tab delimited text file with country, city, Participants field.. Now, when I search for a particular entry for eg. Country England, then I want it to show all the cities associated with it Inot just one). My actual table looks like this.

    Now, If I select England from this MySQL table, then I want MySQL to display me all the corresponding cities for England.
    Like this:

    Not this:

    One thing, all the rows with city names of the corresponding country is fixed to three.
    I loaded the data using LOAD DATA LOCAL INFILE command to load them from my tab delimited text file. I have attached my .txt file.
    Table created using VARCHAR with Default null..
    Could you please tell me the appropriate command for this (like if there's any appropriate LIMIT command or something like that)
    Thanks for your help..
    Attached Files Attached Files

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You must populate the Country column in all the rows.

    The fact that your query pulls results in that order is not deterministic, it's luck, an artifact; one rebuild of the table file and you won't get them back in that order anymore.

    Either edit your .txt file to include the country names with every line, or write a program which inserts the rows with complete data.

  3. #3
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok..thanks..I think i got my answer..

  4. #4
    SitePoint Wizard
    Join Date
    Dec 2003
    Location
    USA
    Posts
    2,582
    Mentioned
    29 Post(s)
    Tagged
    0 Thread(s)
    Keep in mind when dealing with databases that each row is essentially meant to stand on it's own. The order of rows in any specific table has no bearing on anything.


Bookmarks

Posting Permissions

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