Hmm... LIKE is kind of inefficient when you're absolutely sure that the
first letters will be certain things.
I would suggest using LEFT() instead. That way it will only evaluate part
of the string and not the entire string.
SELECT ArticleNo
FROM Items
WHERE LEFT(ArticleNo,2) = 'VC'
--or whatever letters are appropriate.
This should work with any SQL-compliant databases, including MySQL, Access,
and all incarnations of SQL Server
HTH
Arbon Reimer
----- Original Message -----
From: Imar Spaanjaars <Imar@S...>
To: sql language <sql_language@p...>
Sent: Sunday, September 16, 2001 9:06 PM
Subject: [sql_language] Re: Database access
> Hi there,
>
> You can use the LIKE operator, which allows a wild card character like %.
>
> Try this:
>
> SELECT ArticleNo
> FROM Items
> WHERE ArticleNo LIKE 'VC%'
>
> This will select all items that have an articlenumber that starts with VC.
>
> Lookup LIKE in the BOL for more info.
>
> Hope this helps,
>
> Imar
>
> >
> > Hello there,
> >
> > With help of the last chapter I tried to make a database accessing
> script
> > by myself, but got stuck at executing an SQL command.
> > I have a DB file with a field 'ArticleNo' in that field there are
> various
> > article no. that begin with two letters i.e. VC00001, VC00001 and so on.
> > and the same for beginning letters MB and HD.
> > Now I wondered. Is there a way to only select the records that begin
> with
> > two specified letters?
> >
> > I now have
> >
> > SELECT ArticleNo
> > FROM Items
> > WHERE ????????????
> >
> > could anybody help me getting this query right?
> > many thanks in advance.
> >
> > D.
>