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?
Discussion:
16 comments Page 1 of 2.
Anil said:
1 decade ago
In case of char variables the exact match may not be possible. In those cases we use % wildcard.
L.Srinivas said:
1 decade ago
Can you elaborate in detail please.
Jaba said:
1 decade ago
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:
1 decade ago
Please give the answer in more detail.
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..
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%';
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%'
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:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers