WILDCARD can Substitute for one or more characters when searching for data in a database. SQL Wildcard Must be used with the SQL LIKE operator.
| Wildcards | Description |
| The percent sign (%) | It allows you to match any string of any length Means matches one or more characters. Note that MS Access uses the asterisk (*) wildcard character instead of the percent sign (%) wildcard character. |
| The underscore (_) | It allows you to match on a single character means matches one character. Note that MS Access uses a question mark (?) instead of the underscore (_) to match any one character. |
| Employee |
| Emp_id | Name | Surname | Salary | Dept_id |
| 1 | Rajesh | Khanna | 45000 | 2 |
| 2 | Sneha | Gupta | 55000 | 4 |
| 3 | Sandeep | Nehte | 95000 | 1 |
| 4 | Kirti | Patil | 25000 | 3 |
| 5 | Nilesh | Jadhav | 45000 | 3 |
| 6 | Dipesh | Das | 35000 | 5 |
| 7 | Kailash | Rane | 62000 | 1 |
| 8 | Kavita | Deshpande | 48000 | 3 |
| 9 | Sanjay | Datt | 50000 | 2 |
| 10 | Shruti | Hasan | 78000 | 1 |
| 11 | Sandeep | Deshmukh | 52000 | 3 |
| SELECT * FROM Employee WHERE Name LIKE 'S%' |
| Employee |
| Emp_id | Name | Surname | Salary | Dept_id |
| 1 | Sneha | Gupta | 55000 | 4 |
| 2 | Sandeep | Nehte | 95000 | 1 |
| 3 | Sanjay | Datt | 50000 | 2 |
| 4 | Shruti | Hasan | 78000 | 1 |
| 5 | Sandeep | Deshmukh | 52000 | 3 |
or
| SELECT * FROM Employee WHERE Name LIKE '%le%' |
| Employee |
| Emp_id | Name | Surname | Salary | Dept_id |
| 5 | Nilesh | Jadhav | 45000 | 3 |
or
| SELECT * FROM Employee WHERE Name LIKE '_a%' |
| Employee |
| Emp_id | Name | Surname | Salary | Dept_id |
| 1 | Rajesh | Gupta | 55000 | 4 |
| 2 | Sandeep | Nehte | 95000 | 1 |
| 3 | Kailash | Datt | 50000 | 2 |
| 4 | Kavita | Hasan | 78000 | 1 |
| 5 | Sanjay | Deshmukh | 52000 | 3 |
No comments:
Post a Comment