kori Posted November 20, 2019 Share Posted November 20, 2019 Hi! if in data "-" sign sql select not found. - select * from invoice where accnum='19-00/09598' in table 3 record contain '19-00/09598' but found 0 the accnum field incoming data different formats but save in the string field suggestion of soultion ? sorry my english :-) Thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted November 20, 2019 Share Posted November 20, 2019 (edited) check for unseen extra white spacing either end, as you may be searching for string containing '19-00/09598' but it could be ' 19-00/09598', '19-00/09598 ' or ' 19-00/09598 ', if you did not trim any spaces before saving to database. Edited November 20, 2019 by dsonesuk Link to comment Share on other sites More sharing options...
Sherin Posted December 20, 2019 Share Posted December 20, 2019 You can try using select * from invoice where accnum like '%19-00/09598%' or select * from invoice where LTRIM(RTRIM(accnum)) = '19-00/09598' Link to comment Share on other sites More sharing options...
dsonesuk Posted December 20, 2019 Share Posted December 20, 2019 (edited) If only there was a way to trim both left and right spacing without using both LTRIM() and RTRIM...WAIT! There is! ItsTRIM(). Edited December 20, 2019 by dsonesuk Link to comment Share on other sites More sharing options...
Sherin Posted December 20, 2019 Share Posted December 20, 2019 TRIM() function is introduced in SQL Server starting with 2017. So this query will work as per requirement regardless of the version. Link to comment Share on other sites More sharing options...
dsonesuk Posted December 20, 2019 Share Posted December 20, 2019 Oh yea! sorry I forgot MSSQL is about 20years behind MYSQL. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now