Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reverse SQL LIKE

Tags:

sql

postgresql

Is it possible in SQL (more specifically PostreSQL) to match a string against the pattern stored in the table so that when I have a DB field containing %some% I'd be able to select its row by something like

SELECT * FROM table_name WHERE field_value LIKE 'Awesome stuff'

Thanks.

like image 553
jackhab Avatar asked Jan 26 '11 15:01

jackhab


People also ask

What is the opposite of like in SQL?

The NOT LIKE operator in SQL is used on a column which is of type varchar . Usually, it is used with % which is used to represent any string value, including the null character \0 .

What is the opposite of like in MySQL?

In MySQL, you can use NOT LIKE to perform a negation of the LIKE operator. In other words, NOT LIKE returns the opposite result to LIKE .

How do I reverse a SQL query?

SQL Server REVERSE() Function The REVERSE() function reverses a string and returns the result.

What does like %% mean in SQL?

The % is a wildcard that matches any character, and any number of characters. So a LIKE % matches everything. In your case, the LIKE '% %' matches anything that has a space in it.


1 Answers

SELECT  *
FROM    table_name
WHERE   'Awesome stuff' LIKE field_value
like image 196
Quassnoi Avatar answered Oct 04 '22 03:10

Quassnoi