Using wildcard characters in columns

You can use wildcard characters for columns and column names. You might want to create a table called special_discounts in the pubs2 database to run a price projection for a special sale:

create table special_discounts
id_type char(3), discount int)
insert into special_discounts 
values("BU%", 10)
...

The table should contain the following data:

id_type discount     
------- -----------  
BU%              10  
PS%              12  
MC%              15 

The following query uses wildcard characters in id_type in the where clause:

select title_id, discount, price, price - (price*discount/100) 
from special_discounts, titles 
where title_id like id_type 

Here are the results of that query:

 title_id   discount      price                                              
 -------- ----------- -------------- --------------  
 BU1032            10          19.99          17.99  
 BU1111            10          11.95          10.76  
 BU2075            10           2.99           2.69  
 BU7832            10          19.99          17.99  
 PS1372            12          21.59          19.00  
 PS2091            12          10.95           9.64  
 PS2106            12           7.00           6.16  
 PS3333            12          19.99          17.59  
 PS7777            12           7.99           7.03  
 MC2222            15          19.99          16.99  
 MC3021            15           2.99           2.54  
 MC3026            15           NULL           NULL  
 
(12 rows affected) 

This type of example permits sophisticated pattern matching without having to construct a series of or clauses.