sql-like

MYSQL SELECT WHERE LIKE WITH AES_ENCRYPT

二次信任 提交于 2019-11-30 17:43:59
问题 How would I perform a Mysql SELECT with WHERE and LIKE serach if field is AES_ENCYPTED? Example: SELECT AES_DECRYPT(place,'"+salt+"'),AES_DECRYPT(web_address,'"+salt+"') FROM access WHERE place= LIKE '%(AES_ENCRYPT('"+searchStr+"','"+salt+"'))',%') Basically, perform a search on an encrypted column with the LIKE wildcard on both ends of the $searchStr 回答1: You can't search on an encrypted column without first decrypting it. You'll need to do WHERE AES_DECRYPT(like, salt) LIKE '%something%'

Hibernate HQL query by using like operator

ε祈祈猫儿з 提交于 2019-11-30 17:24:23
Seu the following mapping @Entity public class User { private Integer id; @Id; private Integer getId() { return this.id; } } Notice id is an Integer. Now i need this HQL query by using like operator Query query = sessionFactory.getCurrentSession().createQuery("from User u where u.id like :userId"); ATT: IT IS like operator NOT = (equals operator) Then i use List<User> userList = query.setParameter("userId", userId + "%").list(); But does not work because Hibernate complains IllegalArgumentException occured calling getter of User.id Even when i use query.setString("userId", userId + "%"); It

'LIKE ('%this%' OR '%that%') and something=else' not working

最后都变了- 提交于 2019-11-30 16:47:43
I have a select query where I am trying to search strings for multiple patterns LIKE ('%this%' or '%that%' ) and something=else Returns zero results However LIKE '%this%' and something=else returns results and LIKE '%that%' and something=else returns result Is it possible to get all my results into one query? If a string matches both, how will it handle that? It would be nice if you could, but you can't use that syntax in SQL. Try this: (column1 LIKE '%this%' OR column1 LIKE '%that%') AND something = else Note the use of brackets! You need them around the OR expression. Without brackets, it

MySQL - Is it possible to use LIKE on all columns in a table?

…衆ロ難τιáo~ 提交于 2019-11-30 14:40:24
问题 I'm trying to make a simple search bar that searches through my database for certain words. It is possible to use the LIKE attribute without using WHERE? I want it to search all columns for the keywords, not just one. Currently I have this: mysql_query("SELECT * FROM shoutbox WHERE name LIKE '%$search%' ") Which obviously only searches for names with the search input. I tried both of these: mysql_query("SELECT * FROM shoutbox LIKE '%$search%' ") mysql_query("SELECT * FROM shoutbox WHERE *

How to make “LIKE” query work in MongoDB?

…衆ロ難τιáo~ 提交于 2019-11-30 14:35:32
I have a list of street names and I want to select all that start with "Al". In my MySQL I would do something like SELECT * FROM streets WHERE "street_name" LIKE "Al%" How about MongoDB using PHP? Use a regular expression: db.streets.find( { street_name : /^Al/i } ); or: db.streets.find( { street_name : { $regex : '^Al', $options: 'i' } } ); http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-RegularExpressions Turning this into PHP: $regex = new MongoRegex("/^Al/i"); $collection->find(array('street_name' => $regex)); See: http://www.mongodb.org/display/DOCS/SQL+to+Mongo

SQL Server, combining % and [] wildcards in LIKE statement

萝らか妹 提交于 2019-11-30 14:03:58
In t-sql, is there a way to do pattern matching in a like statement such that you can search for 1 or more characters in a given set? To be specific, I'm trying to come up with a LIKE statement that will return strings that begin with 1 or more letters and end in 1 or more numbers. So these strings should match: abcd1234 a1 abcdef2 ab123456 And these strings should not match: abcd 1234 abcd1234abcd 1abcd1 I know you can use the % wildcard to match a string of 0 or more characters, and you can use brackets[] to match a single character in a given set. But is there any way to combine those so

Using LIKE operator with stored procedure parameters

↘锁芯ラ 提交于 2019-11-30 12:02:00
问题 I have a stored procedure that uses the LIKE operator to search for a truck location among some other parameters @location nchar(20), @time time, @date date AS select DonationsTruck.VechileId, Phone, Location, [Date], [Time] from Vechile, DonationsTruck where Vechile.VechileId = DonationsTruck.VechileId and (((Location like '%'+@location+'%') or (Location like '%'+@location) or (Location like @location+'%') ) or [Date]=@date or [Time] = @time) I null the other parameters and search by

MySQL - Is it possible to use LIKE on all columns in a table?

一曲冷凌霜 提交于 2019-11-30 11:21:31
I'm trying to make a simple search bar that searches through my database for certain words. It is possible to use the LIKE attribute without using WHERE? I want it to search all columns for the keywords, not just one. Currently I have this: mysql_query("SELECT * FROM shoutbox WHERE name LIKE '%$search%' ") Which obviously only searches for names with the search input. I tried both of these: mysql_query("SELECT * FROM shoutbox LIKE '%$search%' ") mysql_query("SELECT * FROM shoutbox WHERE * LIKE '%$search%' ") and neither worked. Is this something that is possible or is there another way to go

How to escape underscore character in PATINDEX pattern argument?

痞子三分冷 提交于 2019-11-30 10:42:48
问题 I've found a solution for finding the position of an underscore with PATINDEX : DECLARE @a VARCHAR(10) SET @a = '37_21' PRINT PATINDEX('%_%', @a) -- return 1 (false) PRINT PATINDEX('%!%', REPLACE(@a, '_', '!')) -- return 3 (correct) Have you other ideas? Like a way to escape the underscore character? 回答1: I've always done it with brackets: '%[_]%' 回答2: To match two underscores, each must be bracketed '%[__]%' -- matches single _ with anything after '%[_][_]%' -- matches two consecutive _ 回答3:

SQL SELECT LIKE containing only specific words

天大地大妈咪最大 提交于 2019-11-30 09:25:07
问题 I have this query: SELECT * FROM mytable WHERE column1 LIKE '%word1%' AND column1 LIKE '%word2%' AND column1 LIKE '%word3%' I need to modify this query to return records for which column1 contains word1 word2 and word3 and nothing else! no other words, just these words. Example: searching for samsung galaxy s3 should return any combination of samsung s3 galaxy but NOT samsung galaxy s3 lte 回答1: Assuming that column1 contains space separated words, and you only want to match on whole words,