Forum Moderators: open

Message Too Old, No Replies

ASP Select Statement Question

         

kevinj

10:32 pm on Jan 25, 2003 (gmt 0)

10+ Year Member



I have an Access database that has a table called EXHIBITORS and a field in that table called EXHIBITOR_NAME. I need to select all records from that table with the EXHIBITOR_NAME value starting with the letter A through G. I don't want any records selected that the EXHIBITOR_NAME value H through Z (ie Select Apple record but don't select Hewlett Packard record). What SELECT statement would I need to write to select the records that fit this criteria? Any help is much appreciated.

jatar_k

1:17 am on Jan 26, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



not the access wizard but mysql has a like syntax

select * from from EXHIBITOR where EXHIBITOR_NAME like "A%"

would select all exhibitors that start with A. I imagine there is an access equiv. I don't know if you could use IN or BETWEEN somehow.

Woz

1:27 am on Jan 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Almost Jatar,

to get A through G, try

select * from from EXHIBITOR where EXHIBITOR_NAME like "A%" OR like "B%" OR like "C%" OR like "D%" OR like "E%" OR like "F%" OR like "G%"

or

select * from from EXHIBITOR where LEFT(EXHIBITOR_NAME,1) => "A" AND LEFT(EXHIBITOR_NAME,1) < "h"

This is SQL and independent of data source.

Onya
Woz

aspdaddy

9:59 am on Jan 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



another way ..

SELECT exhibitor_name
FROM exhibitors
where left(exhibitor_name,1) IN ('a','b','c','d','e','f','g')

Or in Access..
left(exhibitor_name,1) like '[a-g]'

kevinj

4:20 pm on Jan 26, 2003 (gmt 0)

10+ Year Member



Thanks everyone. I got it to work exactly as I had hoped. I ended up using ASPDaddy's Select statement.