Raj Raina
Raj Raina

Reputation: 211

SQL "SELECT" Command Not Working, even though entry is in DB

I have created the following database:

CREATE TABLE QuizRepo (
User_ID BIGINT AUTO_INCREMENT PRIMARY KEY,
Name TEXT
)

I populate it via JDBC, and when I populate it, I get:

mysql> select * from QuizRepo;
| User_ID | Name    |
|       1 | "XXQuiz"|

When I do the following command, it works as expected:

mysql> select * from QuizRepo where USER_ID=1;
User_ID | Name      |
|       1 | "XXQuiz"|

However, when I do the following command, I get a weird result

mysql> select * from QuizRepo where Name="XXQuiz";
Empty set (0.01 sec)

Has anyone seen this happen before? How could this be possible? Perhaps I am adding it in the DB incorrectly (doesnt seem likely) but then you can clearly see there is an entry called "XXQuiz" so why is it not finding it?

Upvotes: 1

Views: 312

Answers (2)

FreudianSlip
FreudianSlip

Reputation: 2920

It looks like you've stored the quotes as well. So you'll need to so a : select * from QuizRepo where Name = "\"XXQuiz\"";

or similar.

Upvotes: 3

ScaisEdge
ScaisEdge

Reputation: 133360

Could be you name don't match exactly check for this and try also

select * from QuizRepo where Name like "%XXQuiz%";

Upvotes: 0

Related Questions