A1VBCode Forums

Using LIKE in SQL


http://www.a1vbcode.com/vbforums/Topic32473.aspx

By Kane_W2 - 9/9/2017

Hi,

I have got a SQL statement that fetched data from the table 'authors' and places the data in a datgrid on the form.

This works fine,

Dim default As String "SELECT * FROM authors WHERE authorname = 'Ken Davies' "

The problem occurs when I introduce the LIKE command into the sql statement like this,

"SELECT * FROM authors where authorname LIKE 'Ken Davies' "

All I keep getting is an empty datagrid...

any suggestion much appreciated.
By Admin - 9/10/2017

You need to use wildcards such as % for SQL Server, and * for Access.

where authorname LIKE '%Ken Davies%'