Database - Introduction to SQL - Discussion

Discussion Forum : Introduction to SQL - General Questions (Q.No. 5)
5.
The wildcard in a WHERE clause is useful when?
An exact match is necessary in a SELECT statement.
An exact match is not possible in a SELECT statement.
An exact match is necessary in a CREATE statement.
An exact match is not possible in a CREATE statement.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
16 comments Page 2 of 2.

Peru said:   1 decade ago
SQL wildcards can substitute for one or more characters when searching for data in a database.
SQL wildcards must be used with the SQL LIKE operator.
With SQL,
% A substitute for zero or more characters
_ A substitute for exactly one character

SELECT * FROM Persons
WHERE City LIKE 'sa%'
it will select the row where the city name starts with sa..

Sirisha said:   1 decade ago
What is meant by wildcard can you explain clearly?

Kitty said:   1 decade ago
Can you explain with some more details?

Kirti said:   1 decade ago
Can you explain why Wildcard chars are used to replace any substring?

ARUN said:   1 decade ago
SQL wildcard('%') to find the entire search value or substring of the search value.It is like a grep command, which displays all results which matches that pattern.

For example if you have table student and want to display the student name ends with 'n' then the query will be:

SELECT * FROM STUDENT WHERE name LIKE '%n';

If you want to search name that have 'n' any where in the name:

SELECT * FROM STUDENT WHERE name LIKE '%n%';

Sreedhar said:   1 decade ago
If we consider we have emp table with ename as column.

If we want to get names which starts with Letter B then
select * from emp where ename like '%B%'

If we want to get names which starts with Letter B and ends with E then
select * from emp where ename like 'B%E%'

If we want to get names which ends with Letter B then
select * from emp where ename like 'E%'


Post your comments here:

Your comments will be displayed after verification.