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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-12 : 09:47:33
Dee writes "If you want to find all employees whose name started with "B", What is wrong with the following SQL
statement? 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.

Go to Top of Page

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 ?.



--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -