SitePoint Sponsor

User Tag List

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

    Finding countries with a certain character in the name?

    Alright,

    So I have MySQL Workbench, and the "world" database that comes with it as sample data. Now I have to find all countries that has the letter "W" as the middle character in the land codes in the database.

    Like:
    Code SQL:
    SELECT Code (WITH letter W AS middle CHARACTER)
    FROM Country

    How could I do this?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,323
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    homework assignment?

    could you please do a SHOW CREATE TABLE for the country table
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Home ... work?

    I guess it could be done with '%W%' or similar, but thanks anyway.

  4. #4
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved

    Code SQL:
    SELECT Name, Code
    FROM Country
    WHERE Code LIKE '_W_'

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,323
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    if it's a three-character code, yes, that'll do it

    but we didn't know what size it was, did we, which is why i asked for a SHOW CREATE TABLE

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course, I guess I took for granted that "land codes" are always three characters.


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
  •