Is there any difference between:
SELECT * FROM users WHERE username=\"davyjones\"
and
SELECT * FROM users WHERE username LI
LIKE allows wildcards like % (any number of characters here) and _ (one character here).
SELECT * FROM users WHERE username LIKE 'joe%'
Selects all usernames starting with joe.
LIKE searches for a pattern.
/* Returns all users whose username starts with "d" */
SELECT * FROM users WHERE username LIKE 'd%'
/* Returns all users whose username contains "dav" */
SELECT * FROM users WHERE username LIKE '%dav%'
That will give you the same result. However, LIKE allows wildcards, for example...
SELECT * FROM users WHERE username LIKE 'davy%'
The only syntax problem was double quotes instead of single quotes
create table A (id int,name varchar(30))
insert into A values(4,'subhash')
Use the trailing whitespace to search the name field:
select * from A where name='Subhash '
--Yields 1 row
select * from A where name like 'Subhash '
--Yields 0 row
Like is pattern matching operator and = is exact matching operator. i.e. where name like W% it means start with W and after that one or more characters
and = i.e. where name ='James' this is exact matching
Equals '=' is just for equality. On the other hand, LIKE supports SQL wildcard matching.
So, with LIKE you can do name like '%jones' to get all the names ending in jones. With LIKE, the percent '%' character is anything, length zero or more, and the underscore character, '_', is any one character.