KRIPA SHANKAR
KRIPA SHANKAR

Reputation: 1

Displaying data from an Oracle Table through SQL Query

I am not able to attach a screenshot because I am a new user here. By the way, I am trying to view data from a table through SQL. I have created the table using the following command:-

CREATE TABLE  N2 
   (    BOOK_ID VARCHAR2(6) NOT NULL ENABLE, 
    BOOK_NAME VARCHAR2(150) NOT NULL ENABLE, 
    AUTHOR_ID CHAR(6), 
    PUBLICATION_ID CHAR(6), 
    MAJOR_SUB_ID CHAR(6), 
    MINOR_SUB_ID CHAR(6)
   )

But the problem is that no record is displayed for the query:-

Select * from N2 where book_id='B0001';

though it can be seen that there is a record having book_id=B0001 This problem is removed if I use char type for book_id column or I write

Select * from N2 where book_id like 'B0001%';

One more thing is that this problem doesn't occur with other columns of varchar2 data type.

Please help me.

Upvotes: 0

Views: 41

Answers (1)

Laurent S.
Laurent S.

Reputation: 6947

Classic : you probably have a trailing space of hidden character (line feed) at the end of your data...

you could achieve the same result with :

Select * from N2 where trim(book_id)='B0001';

but it would be better to clean up your data as I presume this character shouldn't be in your ID field

Upvotes: 1

Related Questions