Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
See more:
From my Database (returnShipmentPos) should i get [ReferenceID] where = R-100235729-200'
but i dont get any result . i got just empty column ?!

I will be happy for an explanation

What I have tried:

select ReferenceID 

from returnShipmentPos

where ReferenceID = 'R-100235729-200'
Posted
Updated 6-Sep-19 0:26am
Rate this:
Please Sign up or sign in to vote.

Solution 1

First off, why are you returning a ReferenceID that you already know? If you know it, there is little point in querying a DB to find it ... By all means, return a COUNT or similar, but fetching the value you are filtering by is somewhat silly.

Secondly, if it returns no columns that means there are no values that match in the table - you could be querying the wrong table, the wrong DB, or you could be looking for the wrong ID value. You will not get an "empty column" back from that query: if you are seeing empty columns, I'd look at the "raw data" the query returns and at what you are doign with it subsequent to the SQL call. Without your DB and the data it contains, we can't help you there - so start with SSMS and paste your query into a new query window.
If you get no rows, then change it to:
SELECT ReferenceID FROM returnShipmentPos WHERE ReferenceID LIKE '%R-100235729-200%'
And see if that changes the results. (Equality requires the data to match exactly; LIKE will match if the string is anywhere in the data.
If that doesn't help, remove the WHERE clause entirely, and see exactly what is returned.

Sorry - we can't do any of that for you!
   
Comments
Abdalla Ben Omran 3-Sep-19 4:17am
   
Hey Paul, you don't need to be sorry . you have helped me alot with your cool explanation that what i needed a good explanation is helping me much more than a already code .

so the Value i have entried is 0 rows but with another value it gives me back row with some number .

I thank you like always
OriginalGriff 3-Sep-19 4:24am
   
You're welcome!
Rate this:
Please Sign up or sign in to vote.

Solution 3

The value that you used in your where condition might have some unicode characters which are not visible to naked eye but SQL server might have stored in the column. In that case if you copy the value and use it in your where condition SQL won't do exact comparison with UNICODE values. First try to identify if your referenceId column has any unicode characters in it.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100