View Full Version : SQL Syntax


shamas21
06-02-2008, 12:15 PM
Hi All

Can some tell me what im doing wrong. Im trying to bring back Any field that begin with A or B using the IN Statement.

Thanks

SELECT country, name, amount
FROM tblcountries
WHERE Name IN ('A*','B*'));

WayneRyan
06-02-2008, 12:29 PM
shamas,

WHERE Name IN ('A*','B*'));

The items in the In clause can't contain wildcards. There is no like
operator.

Where Name Like 'A*' Or Name Like 'B*'

Also, Name is a reserved word.

hth,
Wayne

WayneRyan
06-02-2008, 12:36 PM
shamas,

Alternatively:

WHERE Left(Name, 1) IN ('A', 'B'));

Wayne

shamas21
06-02-2008, 01:22 PM
Many thanks Wayne

MSAccessRookie
06-02-2008, 01:31 PM
It looks like you also have an extra ")" (see below)

WHERE Left(Name, 1) IN ('A', 'B'))

WayneRyan
06-02-2008, 05:36 PM
Thanks Rookie,

It happens ...

Should Cut-And-Paste be illegal?

Wayne

MSAccessRookie
06-03-2008, 05:52 AM
Thanks Rookie,

It happens ...

Should Cut-And-Paste be illegal?

Wayne

That would depend on what you are cutting and pasting. :D