SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,643
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    SELECT by non-primary key

    I have a table
    CREATE TABLE IF NOT EXISTS `reviews` (
    `id` smallint unsigned NOT NULL auto_increment,
    `from` varchar(50) NOT NULL,
    `length` varchar(20) NOT NULL default '',
    `date` date NOT NULL,
    `providerid` smallint unsigned NOT NULL,
    PRIMARY KEY (`id`)
    );

    I'm trying to make a query on it that would select a row depending on the providerid
    select * from reviews where providerid = '39';
    but nothing is returned, why is this?

    Thanks
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,810
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The field is defined as being numeric but you are telling it to look for a string. Try removing the quotes around the number.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by lukeurtnowski View Post
    I'm trying to make a query on it that would select a row depending on the providerid
    select * from reviews where providerid = '39';
    but nothing is returned, why is this?
    my first guess is because there actually aren`t any rows in your table with that providerid
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,643
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Yes, that was it, thx
    "Oh, and Jenkins--apparently your mother died this morning."


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
  •