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 1 of 2.

Kailash Chandra said:   3 years ago
Select * From Student
Where student_name like "kai%";

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

Anuradha tekam said:   4 years ago
Explain it answer clearly to get it.

Hans said:   6 years ago
"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).

Pritam Gupta said:   7 years ago
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.

Kondareddy said:   8 years ago
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.

Priyanka said:   9 years ago
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 .

Sreedhar said:   9 years 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%'

ARUN said:   9 years 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%';

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

Kitty said:   10 years ago
Can you explain with some more details?


Post your comments here:

Your comments will be displayed after verification.