Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Dee writes "If you want to find all employees whose name started with "B", What is wrong with the following SQLstatement? and why SELECT last_name, first_name FROM employees WHERE last_name='B*';"
andre
Constraint Violating Yak Guru
259 Posts
Posted - 2002-03-12 : 09:49:50
You need to use LIKE:
SELECT last_name, first_name FROM employees WHERE last_name LIKE 'B*';
or
SELECT last_name, first_name FROM employees WHERE last_name LIKE 'B%';
depending on what database you use.
Nazim
A custom title
1408 Posts
Posted - 2002-03-12 : 10:44:08
if you are using Sql server the second query given by Andre will work.Remember in Sql SErver wild cards are % instead of * and _(underscore) instead of ?.--------------------------------------------------------------