Results 1 to 4 of 4

Thread: MySQL Search... (Resolved)

  1. #1

    Thread Starter
    Lively Member Daschle's Avatar
    Join Date
    Oct 2002
    Location
    Sunnyvale, CA
    Posts
    114

    MySQL Search... (Resolved)

    This is a really basic, stupid question, but I can't find any website which will bloody answer the question.. it's all advanced stuff, and is well beyond my ability to grasp.

    I have a SQL database called "downloads". There's several tables, one of which is "filename" and one of which is "downloads". Obviously, it's a download counter.

    I'm trying to write a query that'll search the database and return the "downloads" value based on a single filename.

    The standard query it uses is..
    SELECT * FROM downloads ORDER BY downloads DESC

    But that generates everything.

    How would I just simply return the value of "downloads" where "filename" is blah, in table "downloads"?

    Thanks.
    Last edited by Daschle; Mar 18th, 2003 at 07:25 PM.
    "It's difficult to imagine a world in which people voluntarily choose to listen to liberals. There is no evidence that it has ever happened. " - Ann Coulter

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Is this what you mean?:

    Code:
    SELECT * FROM downloads WHERE filename='blah.exe' ORDER BY downloads DESC
    Sorry if I'm not understanding correctly.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    This is a really basic, stupid question, but I can't find any website which will bloody answer the question.. it's all advanced stuff, and is well beyond my ability to grasp
    then how can it be a basic, stupid question if you think it is all advanced stuff??
    PHP Code:
    SELECT FROM downloads WHERE filename LIKE '%blah.exe%' ORDER BY downloads DESC 
    this will get all downloads that have the word blah.exe in it. Hobo's will return 1 row that will equal the word blah.

  4. #4

    Thread Starter
    Lively Member Daschle's Avatar
    Join Date
    Oct 2002
    Location
    Sunnyvale, CA
    Posts
    114
    Originally posted by phpman
    then how can it be a basic, stupid question if you think it is all advanced stuff??
    What's advanced to me isn't advaned to you, since that my knowledge of PHP and SQL can be summed up in five or six words.



    Thanks for the info guys. Hobo's code worked perfectly, mainly because I'm able to guarantee that the scope of the file tracking is so limited that there'll never be a duplicate name.

    Some day I'll learn the proper sql syntax so I can actually do more with it than track how many times my useless little program has been downloaded. (Up to 27 now! Yay me!)

    Thnaks.
    "It's difficult to imagine a world in which people voluntarily choose to listen to liberals. There is no evidence that it has ever happened. " - Ann Coulter

Posting Permissions

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



Click Here to Expand Forum to Full Width