[WEB4LIB] SQL/ASP query

Bradzo bradzo at ozemail.com.au
Wed Oct 4 08:11:34 EDT 2000


Ian

Perhaps a

Select * from table where (column1 = "A" OR column1 = "B" or column1 = "C")
AND
column2 = "D"

You can't do an AND and an OR on the same column - it doesn't make sense.
Perhaps your table hasn't been designed correctly?

You could rewrite the above as:

Select * from table where column1 in ("A","B","C") and column2 = "D"

This essentially says give me a list of records where

column1 = "A" OR column1 = "B" OR column1 = "C"
AND
column2 = "D"

Same as the first select statement, but a little clearer since you don't
need the ( and ) around the OR subclause.

A little more info would help - column names, data sets etc.

Hope this helps....


Brad Thomas
Technical Director
Braddon Computing Services



----- Original Message -----
From: "Ian Winship" <ian.winship at unn.ac.uk>
To: "Multiple recipients of list" <web4lib at webjunction.org>
Sent: Wednesday, October 04, 2000 9:39 PM
Subject: [WEB4LIB] SQL/ASP query


> I am trying to produce some asp scripts to search an Access database, but
am
> having difficulty getting the syntax right in the SQLQuery = "Select...
> statement when I want to use AND, OR to require more than one match in the
> same field. I am also a little unclear about the placing of single and
> double quotation marks in the statement.
>
> I have not found any SQL or ASP books or Web sites that state clearly the
> syntax. Can anyone point me to something useful for a beginner.
>
> Thanks.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Ian Winship
> Learning Resources, University of Northumbria at Newcastle
> City Campus Library, Newcastle upon Tyne NE1 8ST, UK
>
>                     ----------------
> e-mail: ian.winship at unn.ac.uk
> phone:  0191 227 4150      fax: 0191 227 4563
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>



More information about the Web4lib mailing list