reza
reza

Reputation: 59

My sql:how to use Wildcard in Subquery?

example:

SELECT country 
FROM data
WHERE city LIKE 
(SELECT LEFT ('jakartada',7));

it's working nicely but if i give delimiter with value:4 ,i must give wildcard like this ---> "%string%" ,where i can give wildcard in the query?

Upvotes: 0

Views: 2686

Answers (2)

zigots007
zigots007

Reputation: 99

why you using sub query?

SELECT * FROM `data` WHERE city LIKE 'jakar%'

Upvotes: 0

duffy356
duffy356

Reputation: 3716

With LIKE you can use the following two wildcard characters in the pattern.

Character   Description
%           Matches any number of characters, even zero characters
_           Matches exactly one character
\%          Matches one “%” character
\_          Matches one “_” character

does this query help you?

SELECT country 
FROM data
WHERE city LIKE CONCAT ('%', (SELECT LEFT ('jakartada',7)), '%');

Upvotes: 4

Related Questions