Alen
Alen

Reputation: 917

Query string with spaces

Is is possible to query string with spaces, a sentence for example, I have following query:

select id_group from groups where title = 'some title with spaces'

And I don't get any results although I have exact title in my database. I also tried with like but it's the same

Upvotes: 2

Views: 5810

Answers (4)

geomagas
geomagas

Reputation: 3280

There's nothing wrong with your query. The only explanation is that there just isn't any row that satisfies the condition.

Upvotes: 1

Robin Andersson
Robin Andersson

Reputation: 87

It is possible. if you are using phpmyadmin you can press on "sql" and then try your code directly in the database. The problem i think is that you may use lack of ' or " or some other type of symbol. The problem can also be that you havent typed the exact same line. It is important to use capital on the same places and so on.

Upvotes: 0

Mariana Hernandez
Mariana Hernandez

Reputation: 1969

Yes, its possible, maybe try with double quotes? y just tried in my database

SELECT * 
FROM  `Faq` 
WHERE faq_pregunta =  "chao que te vaya bien"

and it works

Upvotes: 1

Slowcoder
Slowcoder

Reputation: 2120

Try this to get all titles with a white space.

select id_group from groups where title like '% %';

But you may find performance issues if there are many number of records and if the column is not indexed.

Upvotes: 3

Related Questions