Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4103138
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:55:11+00:00 2026-05-20T20:55:11+00:00

I cannot find the records using the WHERE CLAUSE : SELECT sensor FROM table

  • 0

I cannot find the records using the WHERE CLAUSE :

SELECT sensor FROM table WHERE type = 'FEET'

There are records in the table whose ‘type’ column values are ‘FEET’, so I suppose it’s something wrong about the format. the result would be something more than ‘FEET’ so that it simply can not find those equal to ‘FEET’.

To find out what the records in column type looks like, I used the following codes to print them out:

    queryTem='SELECT type FROM tide_data'   
    curs.execute(queryTem)
    resultsTem=curs.fetchall()
    for resultTem in resultsTem:
        print resultTem
        print resultTem[0]

the resultTem turns out something like:

 ('FEET\n                         ',)

while resultTem[0] turns out like: FEET, which should be ‘FEET\n’.Based on the information above, is there any way I can rewrite the WHERE CLAUSE statement and get the correct records? Since in the statement: WHERE a = value.. a should be a column name, I can not think of a way to do it.

Someone can help me out here? thanks..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T20:55:12+00:00Added an answer on May 20, 2026 at 8:55 pm

    You say “””Since in the statement: WHERE a = value.. a should be a column name”””. Not so, a can be any expression.

    You say “””the resultTem turns out something like: (‘FEET\n ‘,) while resultTem[0] turns out like: FEET, which should be ‘FEET\n'””. Instead of print resultTem[0], use print repr(resultTem[0]). Get into the habit of using repr() in debug situations.

    As others have pointed out, your data needs scrubbing. If there is an index on that type column, the trailing random whitespace will interfere with the indexing. If your database has a function (named e.g. STRIP) that works like Python’s str.strip(), you should be able to fix it with a one-liner something like this:

    UPDATE table SET type = STRIP(type) WHERE type != STRIP(type);
    

    In the meantime, you can do a “startswith” type of query:

    SELECT sensor FROM table WHERE type LIKE 'FEET%'
    

    or use

    SELECT sensor FROM table WHERE STRIP(type) = 'FEET'
    

    Further comments:

    (1) It looks like your output string is 30 characters wide (unless it got mangled by your pasting and my editing:

    ('FEET\n                         ',)
      .... v....1....v....2....v....3
    

    One possible explanation for the extra spaces is that the column data type is CHAR(30). If this is under your control you might like to change it to VARCHAR(30) or just VARCHAR. See this section of the docs and note the “Tip” in the middle of the page.

    (2) It seems there’s no SQL function as easy as str.strip() for removing leading/trailing whitespace. In PostgreSQL you are going to need something like

    TRIM(E' \r\n\t' FROM your_string_expression)
    

    to remove leading and trailing spaces, carriage returns, line feeds, and tabs. See docs here (and here; read section 4.1.2.2. String Constants with C-Style Escapes).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this message: Cannot find the X.509 certificate using the following search criteria:
I have just started using silverlight 2 beta and cannot find how to or
I cannot find comparison of these parsing technique. Which one is most commonly used?
I cannot find this in the documentation anywhere. Does anyone know if this is
I have stfw but I cannot find a simple / standalone way to create
I have a few things that I cannot find a good way to perform
This seems to be a common problem but I cannot find a solution. I
Seemingly simple, but I cannot find anything relevant on the web. What is the
Photoshop has that great: BiCube Shaper option for resizing. However I cannot find an
It seems that Microsoft wants Silverlight to take off, yet I cannot find an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.