can't find the right syntax for this concept in the manual...
i need to do this:
SELECT * FROM `members` WHERE 'username' contains ' ';
// i need to find all the records where people have used a space in their usernames...
is "contains" right, or is the space the problem...?
thanks
glenn
syntax problem
Moderator: General Moderators
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
Code: Select all
SELECT * FROM `members` WHERE 'username' contains '%text%';Code: Select all
Error
SQL-query :
SELECT *
FROM `members`
WHERE 'username'contains % m %
LIMIT 0 , 30
MySQL said:
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'contains '%me%' LIMIT 0, 30' at line 3Not sure about CONTAINS, but using LIKE does the trick for me:
The latest version of MySQL also supports a REGEXP keyword that you can use for more advanced expressions.
Code: Select all
select * from members where username LIKE '% %';You can try:
or:
% - Stands for Wildcard. For exaple if you type:
and row looks like this:
someone
something
yosuke
it will display: yosuke, becuase it will search for username who ends with uke.
Code: Select all
SELECT username FROM members WHERE username like ' ';Code: Select all
SELECT username FROM members WHERE username like '% %';Code: Select all
SELECT username FROM members WHERE username like '%uke';someone
something
yosuke
it will display: yosuke, becuase it will search for username who ends with uke.