Wildcard Operators in SQL

Wildcard Operators in SQL

Right now, will learn Wildcard administrators in SQL (Structured Query Language). Figure out how to utilize trump card administrator in SQL Query?

Trump card administrators are utilized related to like administrator to upgrade the pursuit in a table.

Trump card characters (% or _) can be utilized anyplace (left, right, in the middle of) in a word.

We may utilize various trump card characters in a solitary word rely upon our prerequisites.

  • % (Percentage or percent sign)
  • _ (Underscore)

1) % (Percentage or percent sign):

This special case character speaks to zero, one or more character (for example this is accessible for coordinating a string for any number of characters (0, 1, 2, … etc)).

Syntax:

SELECT column_name(s) from table_name like '%ppp%';

Here, “ppp” is any mix of a word or string.

Database table:

EidEnameSalary
101preeti20000
102apoorv40000
103antima50000
104rahul10000
105pankaj5000

Example 1: Write an inquiry to discover all workers whose name begins with ‘p’:

SELECT ename from employee where ename like 'p%';

Output:

    ename
    preeti
    pankaj

Example 2: Write a question to discover all representatives ids whose name closes with ‘I’:

SELECT eid from employee where ename like '%i';

Output:

    Eid
    101

2) _ (Underscore)

This special case character speaks to just one character (for example this is accessible for coordinating a string for a solitary character just (for example not contrast and at least zero than one character)).

Syntax:

SELECT column_name(s) from table_name like '_uuu_';

Here, “uuu” is any mix of a word or string.

Example 1: Write an inquiry to discover all representatives whose name of the second letter begins with ‘p’:

SELECT ename from employee where ename like '_p%';

Output:

    ename
    apoorv

Syntax:

Example 2: Write a question to discover all workers ids whose name’s very late letter closes with ‘I’:

SELECT eid from employee where ename like '%u_';

Output:

    ename
    apoorv

Recent Posts

error: Alert: Content is protected!!