Thread: Select Stmt

    #1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Posts
    958
    Rep Power
    16

    Select Stmt


    Thanks for taking the time to read my question.

    I'm new to MySQL (I've got all my books in front of me) and I'm trying to select all records frm tblRoster where 'Team' is LIKE 'Coyotes'

    I can't seem to get it to work
    SELECT 'Team'
    FROM 'tblRoster'
    WHERE 'Team' LIKE "Coyotes'
    If I use PHPMyAdmin and use the Search tab, it make a query that looks like this
    SELECT *
    FROM `tblRoster`
    WHERE `Team` LIKE CONVERT( _utf8 'coyotes'
    USING latin1 )
    COLLATE latin1_general_ci
    LIMIT 0 , 30
    Why does it add all that extra stuff? Do I have the wrong Collation on the field? I was told I should use this. Should I use a different one? I don't want to have to do the CONVERT every time I make a query.

    Thanks again,

    Brad
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,178
    Rep Power
    4274
    'Team' -- this is a string

    `Team` -- this is a valid delimited identifier, but the identifier delimiters are not required

    Team -- this is a valid identifier, and is what you should be using

    ignore that other stuff phpmyadmin creates -- it's one of the worst tools around for producing useful sql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Posts
    958
    Rep Power
    16
    Great!! Thanks,

    So then taking that what am I doing wrong here?

    INSERT INTO tblRoster (Country) VALUES ('Canada')
    WHERE Team LIKE 'Coyotes'
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,178
    Rep Power
    4274
    what is wrong is that the INSERT statement does not permit a WHERE clause
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Posts
    958
    Rep Power
    16
    Sorry for my slow reply. I had to step away for a bit.

    I've been looking around but haven't found anything yet.... how do you update only specific records.... oh... I just answered my own question.

    UPDATE query.

    You know, some days I wonder how I get dressed in the morning.

    Thanks for your help.

    Brad
  10. #6
  11. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,178
    Rep Power
    4274
    reminds me of icanhascheezburger.com

    I'M IN UR CLOSET...
    ... STEALIN' UR CLOZE

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo