Is it possible to use LEFT and WHERE in a sql statement

I am trying to produce a quick A-Z index of items stored in my database based on the initial letter of the product.

For instance, I will have

A B C D E F .... at the top of the page and then below it a dynamic table which will show only those products beginning with A etc

Is it possible to write something like as the SQL statement

SELECT "aaa,bbb,ccc from tbl_xxx where LEFT(aaa,1) = "+Request("Initial")

I am getting invalid column name

Is there an easy SQL way to do this...

Thanks
roblickleyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
yes, it would be something like this:
sql = "SELECT aaa,bbb,ccc from tbl_xxx where aaa LIKE '" +Request("Initial") + "%' "

Open in new window

0
Pratima PharandeCommented:
SELECT aaa,bbb,ccc from tbl_xxx where aaa  like '"+ Request("Initial") +"'%"
0
Pratima PharandeCommented:
actual query is like this

SELECT aaa,bbb,ccc from tbl_xxx where aaa  like 'a%'
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

roblickleyAuthor Commented:
"SELECT * FROM dbo.tbl_aaa where left(aaa,1) = '" + Request("Initial") + "'"

missed off the " !!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
glad that you found your solution, note though that the LIKE method pratima_mcs and I suggest will result in eventually better performance, as it could use an index.
your method using LEFT() on the field will make that impossible...
0
Vee_ModCommented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.