Jump to content

Problem with SELECT


Go to solution Solved by LeedsLad,

Recommended Posts

I have a table, tblConductor, with fields CondID, CondSURNAME, CondOTHERNAMES, CondBORN, CondDIED, CondNATIONALITY.  This table has 3 records (identical except for CondID which is the primary key).  If I run the query

 

SELECT * FROM tblConductor

 

the result id three records as I would expect.  When I run the query

 

SELECT * FROM tblConductor WHERE CondSURNAME = 'Britten'

 

the result is just 1 record which happens to be the third record in the table.

 

It seems to me that the two queries in this case are identical (all three records have CondSURNAME = 'Britten') so why is the outcome different?

Link to comment
https://forums.phpfreaks.com/topic/281900-problem-with-select/
Share on other sites

The other two records must have some difference in the value for CondSURNAME. Perhaps extra spaces around the word, or other invisible characters. Perhaps they are a different case and you're using a case-sensitive collation.

 

Run this query to check the values:

SELECT HEX(CondSURNAME) FROM tblConductor
If all three rows are truly identical that will return three identical rows. If there is a difference in spacing, you will see different values.
Link to comment
https://forums.phpfreaks.com/topic/281900-problem-with-select/#findComment-1448355
Share on other sites

Those strings are a sequence of hex codes, each pair of characters represents one of the original characters. You can see that the only difference between the two strings is the extra 20 at the front:

204272697474656E 
  4272697474656E
If you check the ascii chart (Hx column) you can see that hex code 20 corresponds to a space character, meaning two of your rows have an extra space at the front of their value.
Link to comment
https://forums.phpfreaks.com/topic/281900-problem-with-select/#findComment-1448358
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.