sql-like

SQL query to match one of multiple strings

独自空忆成欢 提交于 2019-12-21 09:19:13
问题 I have following data in table: +----------------------+----------------------------------------------------------+--------------+ | subscriber_fields_id | name | field_type | +----------------------+----------------------------------------------------------+--------------+ | 143 | Peshawar/Islamabad/Lahore/Swat/Mardan/Karachi | Job Location | | 146 | Karachi | Job Location | | 147 | Lahore and Karachi | Job Location | | 149 | Karachi, Mirpur Khas, Sukkur, Layyah, Gilgit, Charsaddah | Job

SQL query to match one of multiple strings

懵懂的女人 提交于 2019-12-21 09:18:50
问题 I have following data in table: +----------------------+----------------------------------------------------------+--------------+ | subscriber_fields_id | name | field_type | +----------------------+----------------------------------------------------------+--------------+ | 143 | Peshawar/Islamabad/Lahore/Swat/Mardan/Karachi | Job Location | | 146 | Karachi | Job Location | | 147 | Lahore and Karachi | Job Location | | 149 | Karachi, Mirpur Khas, Sukkur, Layyah, Gilgit, Charsaddah | Job

MYSQL use 'LIKE' in 'WHERE' clause to search in subquery

笑着哭i 提交于 2019-12-21 07:24:20
问题 How would you use 'LIKE' to search in a subquery? E.g. i've tried doing this, but doesn't work: SELECT * FROM mytable WHERE name LIKE '% (SELECT name FROM myothertable) %' I have this so far: SELECT * FROM t1 WHERE t1.name IN (SELECT t2.name FROM t2) AND (t1.title IN (SELECT t2.title FROM t2) OR t1.surname IN (SELECT t2.surname FROM t2)) It's working ok as it returns exact matchs, but it doesn't seem to return my other records that are similar, so I would like to also check that: t1.title

Hive query with multiple LIKE operators

爷,独闯天下 提交于 2019-12-21 02:19:11
问题 What would be the right way to write a Hive query with multiple LIKE operators like this: SELECT * FROM some_table WHERE some_col LIKE '%abc%' OR some_col LIKE '%xyz%' OR some_col LIKE '%pqr%' OR ... (some more LIKE statements) I tried doing the above as well as WHERE some_col LIKE '%abc|pqr|xyz%' but they didn't return any results. It works fine if I write separate queries, i.e. WHERE some_col LIKE '%abc%' -> returns results and WHERE some_col LIKE '%pqr%' -> also returns results 回答1: From

Pandas text matching like SQL's LIKE?

和自甴很熟 提交于 2019-12-20 16:34:20
问题 Is there a way to do something similar to SQL's LIKE syntax on a pandas text DataFrame column, such that it returns a list of indices, or a list of booleans that can be used for indexing the dataframe? For example, I would like to be able to match all rows where the column starts with 'prefix_', similar to WHERE <col> LIKE prefix_% in SQL. 回答1: You can use the Series method str.startswith (which takes a regex): In [11]: s = pd.Series(['aa', 'ab', 'ca', np.nan]) In [12]: s.str.startswith('a',

Using SQLServer contains for partial words

时光总嘲笑我的痴心妄想 提交于 2019-12-20 10:29:16
问题 We are running many products search on a huge catalog with partially matched barcodes. We started with a simple like query select * from products where barcode like '%2345%' But that takes way too long since it requires a full table scan. We thought a fulltext search will be able to help us here using contains. select * from products where contains(barcode, '2345') But, it seems like contains doesn't support finding words that partially contains a text but, only full a word match or a prefix.

LIKE with % on column names

安稳与你 提交于 2019-12-20 09:48:42
问题 Here is my query that results in a syntax error: SELECT * FROM account_invoice,sale_order WHERE sale_order.name LIKE %account_invoice.origin% The account_invoice.origin field contains the text of sale_order.name, plus other text as well, so I need to match sale_order.name string anywhere in the account_invoice.origin string. I'm using PostgreSQL 8.4. 回答1: Try this SELECT * FROM account_invoice,sale_order WHERE sale_order.name LIKE '%' || account_invoice.origin || '%' % needs single quote

two words and blank spaces not working in MYSQL query using LIKE

烂漫一生 提交于 2019-12-20 07:30:21
问题 i'm making a searcher for my site and this works fine with one word querys $consulta = mysql_query("SELECT * FROM recetas WHERE (titulo LIKE '%$busqueda%' OR intro LIKE '%$busqueda%' OR extra LIKE '%$busqueda%') ORDER BY id DESC"); But if i type 'two words' it doesn't give me result, $busqueda it's result from a <input/> given through $_POST['TERM'] any idea what i'm missing? SOLVED i was missing to encode the variable to URI... oops haha THANKS! 回答1: Think of how your query will look at the

Order of LIKE clause in query when wanting to use multiple terms

大城市里の小女人 提交于 2019-12-20 04:12:12
问题 I have the query SELECT * FROM images WHERE tags LIKE '%example%hello%' I would like the database to select rows which have 'example' and 'hello' in the 'tags' column in any order, as in: A row with 'hello, test, example', also 'example, hello, test' or any other variation of this order. Is this possible, even without using LIKE? The rows must all contain everything specified with LIKE. EDIT: Such as, when I provide 'example' and 'hello' in the query, rows returned must contain both 'example'

Order of LIKE clause in query when wanting to use multiple terms

让人想犯罪 __ 提交于 2019-12-20 04:12:03
问题 I have the query SELECT * FROM images WHERE tags LIKE '%example%hello%' I would like the database to select rows which have 'example' and 'hello' in the 'tags' column in any order, as in: A row with 'hello, test, example', also 'example, hello, test' or any other variation of this order. Is this possible, even without using LIKE? The rows must all contain everything specified with LIKE. EDIT: Such as, when I provide 'example' and 'hello' in the query, rows returned must contain both 'example'