Thursday, January 28, 2016

SQL QUERY WILDCARD: Display Values Based on a String Pattern Using SQL Query Like and SQL Query Wildcard

We often search to find a certain data easily in our database. Such as searching for a friends name in facebook. And perhaps, searching for a book in an Online Public Access Catalog (OPAC).

SQL Wildcard is commonly used to find for a certain pattern based on a string. Let's say, you want to display all city that contains "ay". To be able to do this, we need to use sql wildcards which is represented by a percent sign (%). So you need to put a percent sign (%) on both sides. It means you can insert/put any values before and after the letters "ay".

Table

CUSTOMER














SQL Query
select customer_address from customer where customer_address LIKE "%ay%"

Output
The output didn't include Bago City since Bago City does not contain "ay".

Another sql wildcard is the underscore (_). It represents a single character only. Let's say a_c will match values abc, adc but not abb.



SQL QUERY WILDCARD: Display Values Based on a String Pattern Using SQL Query Like and SQL Query Wildcard

SQL QUERY WILDCARD: Display Values Based on a String Pattern Using SQL Query Like and SQL Query Wildcard Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment