470,594 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,594 developers. It's quick & easy.

Mysql sql like

What should I write after sql like for finding hole words
and not for words in string sequence. I tryied "like space variable space"
but it's not working for me. Database is MYSQL.
Jul 19 '05 #1
6 6193
tomek wrote:
Sorry, but I didn't understand the question. I give you a few examples,
hopefully they help:

# Only names that contain Jack and only Jack are returned
select * from tablename where name like 'Jack';

But when i wrote select with like 'oki' I haven't got returned result
though in database there are words oki for example in sentence
'Teczki Oki rozdane'


# If we have 6 rows and the column we search for has these values
# 'Teczki Oki rozdane'
# 'TeczkiOkirozdane'
# 'Oki rozdane'
# 'Teczki Oki'
# 'Oki'
# 'Jack'

# For exact match
# columns like this would match:
# 'Teczki Oki rozdane'
select * from tablename where columnname like 'Teczki Oki rozdane';

# To select all rows where columnname has Oki in the middle of it. i.e.
# columns like this would match:
# 'Teczki Oki rozdane'
# 'TeczkiOkirozdane'
# 'Oki rozdane'
# 'Teczki Oki'
# 'Oki'
select * from tablename where columnname like '%Oki%';

# Same as abow, except there must be whitespace surrounding the word
# i.e. columsn like this would match:
# 'Teczki Oki rozdane'
select * from tablename where columnname like '% Oki %';

# This might get slow with large amounts of data, but it will return
# 'Teczki Oki rozdane'
# 'Oki rozdane'
# 'Teczki Oki'
# 'Oki'
select * from tablename where name like '% Oki %' or name like 'Oki %'
or name like '% Oki' or name like 'Oki';

Jul 19 '05 #2
tomek wrote:
What should I write after sql like for finding hole words
and not for words in string sequence. I tryied "like space variable space"
but it's not working for me. Database is MYSQL.


Sorry, but I didn't understand the question. I give you a few examples,
hopefully they help:

# Only names that contain Jack and only Jack are returned
select * from tablename where name like 'Jack';

# Only names that have Jack somewhere in it. i.e. 'I like Jack'
# are returned.
select * from tablename where name like '%Jack%';

# Only names that match for Jack or Lisa are returned
select * from jack where name like 'Jack' or name like 'Lisa';
Jul 19 '05 #3
> Sorry, but I didn't understand the question. I give you a few examples,
hopefully they help:

# Only names that contain Jack and only Jack are returned
select * from tablename where name like 'Jack';


But when i wrote select with like 'oki' I haven't got returned result
though in database there are words oki for example in sentence
'Teczki Oki rozdane'


Jul 19 '05 #4
tomek wrote:
Sorry, but I didn't understand the question. I give you a few examples,
hopefully they help:

# Only names that contain Jack and only Jack are returned
select * from tablename where name like 'Jack';

But when i wrote select with like 'oki' I haven't got returned result
though in database there are words oki for example in sentence
'Teczki Oki rozdane'


# If we have 6 rows and the column we search for has these values
# 'Teczki Oki rozdane'
# 'TeczkiOkirozdane'
# 'Oki rozdane'
# 'Teczki Oki'
# 'Oki'
# 'Jack'

# For exact match
# columns like this would match:
# 'Teczki Oki rozdane'
select * from tablename where columnname like 'Teczki Oki rozdane';

# To select all rows where columnname has Oki in the middle of it. i.e.
# columns like this would match:
# 'Teczki Oki rozdane'
# 'TeczkiOkirozdane'
# 'Oki rozdane'
# 'Teczki Oki'
# 'Oki'
select * from tablename where columnname like '%Oki%';

# Same as abow, except there must be whitespace surrounding the word
# i.e. columsn like this would match:
# 'Teczki Oki rozdane'
select * from tablename where columnname like '% Oki %';

# This might get slow with large amounts of data, but it will return
# 'Teczki Oki rozdane'
# 'Oki rozdane'
# 'Teczki Oki'
# 'Oki'
select * from tablename where name like '% Oki %' or name like 'Oki %'
or name like '% Oki' or name like 'Oki';

Jul 19 '05 #5
tomek wrote:
Sorry, but I didn't understand the question. I give you a few
examples,hopefully they help:

# Only names that contain Jack and only Jack are returned select *
from tablename where name like 'Jack';


But when i wrote select with like 'oki' I haven't got returned result
though in database there are words oki for example in sentence 'Teczki
Oki rozdane'


Perhaps 'oki' <> 'Oki'.

--
Double your drive space - delete Windows!

Jul 19 '05 #6
tomek wrote:
Sorry, but I didn't understand the question. I give you a few
examples,hopefully they help:

# Only names that contain Jack and only Jack are returned select *
from tablename where name like 'Jack';


But when i wrote select with like 'oki' I haven't got returned result
though in database there are words oki for example in sentence 'Teczki
Oki rozdane'


Perhaps 'oki' <> 'Oki'.

--
Double your drive space - delete Windows!

Jul 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gary Broughton | last post: by
6 posts views Thread by jacob nikom | last post: by
175 posts views Thread by Sai Hertz And Control Systems | last post: by
39 posts views Thread by Mairhtin O'Feannag | last post: by
7 posts views Thread by Randy | last post: by
Atli
6 posts views Thread by Atli | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.