Alex Rivera | Logout

Can you use an asterisk (*) to filter a column in a WHERE clause under SQL Server 2008?

Asked 2011-06-16T18:11:19.987
12

For example

SELECT * FROM movies WHERE director=*
Edit
Report

3 Answers

7

You can use LIKE;

SELECT * FROM movies WHERE director LIKE '%' --all
SELECT * FROM movies WHERE director LIKE 'john landis' --exact
SELECT * FROM movies WHERE director LIKE 'steve%berg' --with wildcard
answered 2011-06-16T18:13:19.267
1

If you are looking for a director represented by * you would have to enclose it in between single quotes:

SELECT * FROM movies WHERE director='*'

If you're looking for any director just leave the where on out.

answered 2011-06-16T18:23:28.107
1
select * from movies where director like '%' 

This will NOT return every row: rows where director is null will be omitted (at least with MSSQL).

answered 2011-06-17T14:03:17.987

Your Answer