PDA

Click to See Complete Forum and Search --> : MySQL Search... (Resolved)


Daschle
Mar 14th, 2003, 12:16 PM
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.

The Hobo
Mar 14th, 2003, 02:39 PM
Is this what you mean?:

SELECT * FROM downloads WHERE filename='blah.exe' ORDER BY downloads DESC

Sorry if I'm not understanding correctly.

phpman
Mar 18th, 2003, 07:46 AM
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?? :p

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.

Daschle
Mar 18th, 2003, 06:24 PM
Originally posted by phpman
then how can it be a basic, stupid question if you think it is all advanced stuff?? :p

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. :D



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.