SQL: If text contains "Mike", then...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the script:

SELECT *
FROM MyTable
WHERE ID
Where Name = "Mike"

What do I put around "Mike" to make it so that anything that contains Mike
will do.
 
I have the script:

SELECT *
FROM MyTable
WHERE ID
Where Name = "Mike"

What do I put around "Mike" to make it so that anything that contains Mike
will do.

Well you have an inconsistency.

WHERE ID
Where Name = "Mike"

Where ID what?

If you are looking just for the [NameField], then

SELECT *
FROM MyTable
Where MyTable.NameField Like "*Mike*"

will find any record that contains Mike anywhere in the field.
 
Yes thanks!
fredg said:
I have the script:

SELECT *
FROM MyTable
WHERE ID
Where Name = "Mike"

What do I put around "Mike" to make it so that anything that contains Mike
will do.

Well you have an inconsistency.

WHERE ID
Where Name = "Mike"

Where ID what?

If you are looking just for the [NameField], then

SELECT *
FROM MyTable
Where MyTable.NameField Like "*Mike*"

will find any record that contains Mike anywhere in the field.
 
Back
Top