'LIKE' or '=' in SQL statement

Hi Experts!

Please can someone explain when it is used ' LIKE' instead of '=' in the Where clause? Could it work with "WHERE Job_Code = '03%' " as well?

Here is the problem and the answer:

What is the pay type for all the job codes that start with '03'? The code has been started for you, but you will need to program the fourth and fifth lines yourself before running the query.

Select

job_code,

pay_type

From salary_range_by_job_classification

WHERE Job_Code LIKE '03%'

Thanks!

LIKE '03%' will match '03' followed by no chars or any chars: For example, these values for Job_Code would be LKE that and be SELECTed:
03
03A
0312234-80

= means the value must match exactly. So, the only value that would match = '03%' is:
03%

1 Like

Thanks for the reply!

Oh, so it wrote Where Job_Code = '03', it will only be searched by '03'?

Using the wildcards, you need to use the LIKE clause, correct?

Thanks!

Exactly correct.

1 Like

in SQL, the "=" operator is used to check for exact matches in the WHERE clause of a query. On the other hand, the "LIKE" operator is used to match a pattern specified by a string. The "LIKE" operator is commonly used with wildcard characters such as "%" and "_" to match any character or a single character, respectively.

1 Like

Well explained.
Thank you!!!