Database - Introduction to SQL - Discussion

Discussion :: Introduction to SQL - General Questions (Q.No.5)

5. 

The wildcard in a WHERE clause is useful when?

[A]. An exact match is necessary in a SELECT statement.
[B]. An exact match is not possible in a SELECT statement.
[C]. An exact match is necessary in a CREATE statement.
[D]. An exact match is not possible in a CREATE statement.

Answer: Option B

Explanation:

No answer description available for this question.

Anil said: (Dec 3, 2010)  
In case of char variables the exact match may not be possible. In those cases we use % wildcard.

L.Srinivas said: (Jun 25, 2011)  
Can you elaborate in detail please.

Jaba said: (Jul 19, 2011)  
Wildcard chars are used to replace any substring.for eg if you want to write a query to get the names which starts with s, we can write it as select * from employee where name LIKE "s%" and - replace single character.

Khushboo Jain said: (Sep 12, 2011)  
Please give the answer in more detail.

Peru said: (Mar 8, 2012)  
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: (Jul 27, 2013)  
What is meant by wildcard can you explain clearly?

Kitty said: (Aug 13, 2013)  
Can you explain with some more details?

Kirti said: (Sep 11, 2013)  
Can you explain why Wildcard chars are used to replace any substring?

Arun said: (Nov 9, 2013)  
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: (Nov 25, 2013)  
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%'

Priyanka said: (Jan 12, 2014)  
Wildcard is use to find SUBSTRING.

There are 3 methods for using these,

1) % It substitutes zero or more character.

Eg: select * from details where city LIKE 'ber%';
->It returns citynames start with 'ber'.

2) _ it substitutes only 1 character.

Eg: select * from details where city LIKE '_erlin';
->It returns cityname start with any character followed by 'erlin'.

3) [charlist] Sets range of character.

Eg: select * from details where city LIKE '[a-c]%';
->It returns cityname start with a,b or c .

Kondareddy said: (Dec 24, 2014)  
Hello friends,

Answer is an exact match is not possible in a select statements. Because if you want to display the name start with 'sa'. But unfortunately our database have 4 records start with sa. For this you write query like this select ename from emp where ename like 'sa%';

Here 4 records are displayed so we can't find the exact match.

Pritam Gupta said: (Nov 19, 2015)  
Wild card basically use for missing character. Suppose there are 100 employee, and I want those employee whose name end with 'M' than I am writing like this:

Select EMP_NAME from EMPLOYEE where EMP_NAME like '%M';

Then I will get all employee name whose end character is M.

Hans said: (Oct 26, 2016)  
"The wildcard in a WHERE clause" makes no sense whatsoever. The WHERE clause has not "wildcards". The LIKE operator supports wildcards, but not the WHERE clause (and together with CREATE the term wildcard makes even less sense).

Anuradha Tekam said: (Sep 27, 2018)  
Explain it answer clearly to get it.

Kailash Chandra said: (Jan 16, 2020)  
Select * From Student
Where student_name like "kai%";

This is the select all student name where name starts with "kai".

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.