Results 1 to 8 of 8

Thread: SQL Length Question

  1. #1
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469

    SQL Length Question

    I am sure one of you sql gurus will know the answer to this. I want to check an sql field for its length and only select items which contain more then 800 characters. Here is hte code I am using that DOES NOT work


    "SELECT * FROM monkey WHERE CHECK length(pet) > 800) ORDER BY views DESC";

  2. #2
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    I think your problem is you can't filter based on blob or memo fields, which I suspect your field "pet" is. Try creating a query that returns the length of "pet" for one record and see if you get a valid number. If you don't you'll know you can't use this method.
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  3. #3
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    can you give me a sample sql blurb ?

  4. #4
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    select length(pet) as plength from table limit 1
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  5. #5
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    Ok so I got a value. Does anyone now know how I can do a check and only list those with a value greater then 800? IE more then 800 chars. Thanks guys. I should add the code that I pasted in my original post doesnt cause an error just doesnt work

  6. #6
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    got it working thanks guys. It was a mixup in the sql and how i nested it.

  7. #7
    Site Contributor KLB's Avatar
    Join Date
    Feb 2006
    Location
    Saco Maine
    Posts
    1,181
    Excellent news! BTW, which SQL database server are you using?
    Ken Barbalace - EnvironmentalChemistry.com (Environmental Careers, Blog)
    InternetSAR.org: Volunteers Assisting Search and Rescue via the Internet
    My Firefox Theme Classic Compact: Based onFirefox's classic theme but uses much less window space

  8. #8
    Gimme Fries with that!
    Join Date
    Aug 2004
    Posts
    1,469
    thanks for the help KLB and Chris you helped me get on the right track. And KLB I have no clue I count on Nexcess for that stuff lol.

Similar Threads

  1. Basic design question
    By izwar in forum HTML, CSS, Layout, and Design
    Replies: 11
    Last Post: 05-11-2006, 09:40 AM
  2. M6.Net has the SQL plan for developers looking for space and freedom.
    By priyanka-m6.net in forum The Marketplace
    Replies: 0
    Last Post: 07-21-2005, 09:29 PM
  3. Replies: 0
    Last Post: 03-27-2005, 05:37 AM
  4. Is there any recommended length for alt text?
    By sitepointRefugee in forum Search Engine Optimization
    Replies: 4
    Last Post: 03-27-2004, 02:36 AM
  5. Multiple SQL queries
    By chromate in forum Website Programming & Databases
    Replies: 21
    Last Post: 02-05-2004, 11:58 AM

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
  •