sql-like

Oracle query using 'like' on indexed number column, poor performance

狂风中的少年 提交于 2019-12-13 12:01:25
问题 On Query 1 a full table scan is being performed even though the id is an indexed column. Query 2 achieves the same result but much faster. If Query 1 is run returning an indexed column then it returns quickly but if non-indexed columns are returned or the entire row is then the query takes longer. In Query 3 it runs fast but the column 'code' is a VARCHAR2(10) in stead of a NUMBER(12) and is indexed the same way as 'id'. Why does Query 1 not pick up that it should use the index? Is there

SQL Like statement not working in Visual Basic

强颜欢笑 提交于 2019-12-13 09:49:28
问题 Dim strText As String = tbRefine.Text Dim sql As String = "SELECT user_name,forename,surname,game_cash,reg_group FROM tblGame WHERE user_name LIKE '" + strSearchText + "' & '*'" Dim dsRefine As New DataSet GetDataset(sql, "tblGame", dsRefine) MsgBox(dsRefine.Tables("tblGame").Rows(0).Item(2).ToString) This is not working, it crashes and says there is nothing in the dataset. I know the dataset function works as its worked successfully before. When i print out the sql statement into microsoft

Search returns no rows in mysql query using LIKE and values having “\”

徘徊边缘 提交于 2019-12-13 05:14:05
问题 I have some problem regarding the search in mysql. Below is my query. SELECT * FROM table WHERE name LIKE "%admin\'s%"; When i am executing this query it will return zero data. actually i have "admin\'s" stored in db. this "\" is to prevent sql injection. i have used mysql_real_escape_string to prevent the sql injection. but when i use three times addslashes to my variable it works. So my below query is working. SELECT * FROM table WHERE name LIKE "%admin\\\\\\\'s%"; My above query will

MySQL Update query with LIKE in WHERE clause not affecting matching rows

人走茶凉 提交于 2019-12-13 05:09:42
问题 This is driving me crazy. I do a SELECT first to make sure records exist: Select * from gems WHERE page2 like '%acids-bases-salts%' and get Showing rows 0 - 8 ( 9 total, Query took 0.0012 sec) Then try to UPDATE to change those records: UPDATE gems SET page2 = replace(page2, 'acids-bases-salts', 'abs') WHERE page2 LIKE '%acids-bases-salts%' and get 0 rows affected. ( Query took 0.0019 sec ) What am I missing? This is simple one time query so I am not worried about performance. 回答1: OK got it.

MySQL returns incorrect UTF8 extended characters in some cases only

て烟熏妆下的殇ゞ 提交于 2019-12-13 01:59:47
问题 Note: In the following question you may see ? or blocks instead of characters, this is because you don't have the appropriate font. Please ignore this. Background I have a table with data structured as follows: CREATE TABLE `decomposition_dup` ( `id` int(11) NOT NULL AUTO_INCREMENT, `parent` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `structure` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, `child` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, PRIMARY KEY (`id`), KEY `parent` (

PHP variable and MySQL LIKE query is not working

故事扮演 提交于 2019-12-13 01:50:16
问题 I have the following code: $surname=$_POST['surname']; $sql2="SELECT * FROM andriana WHERE surname LIKE '$surname%'"; if (!mysql_query($sql2,$con)){ die('Error: ' . mysql_error()); } $result2 = mysql_query($sql2); echo "<table>"; while ($data = mysql_fetch_array($result2)) { echo "<tr>"; echo "<td style='width:100px;height:40px'>".$data['name']."</td>"; echo "<td style='width:100px;height:40px'>".$data['surname']."</td>"; echo "<td style='width:100px;height:40px'>".$data['checkIN']."</td>";

Combine 'like' and 'in' in a SqlServer Reporting Services query?

时光怂恿深爱的人放手 提交于 2019-12-12 20:03:43
问题 The following doesn't work, but something like this is what I'm looking for. select * from Products where Description like (@SearchedDescription + %) SSRS uses the @ operator in-front of a parameter to simulate an 'in', and I'm not finding a way to match up a string to a list of strings. 回答1: There are a few options on how to use a LIKE operator with a parameter. OPTION 1 If you add the % to the parameter value, then you can customize how the LIKE filter will be processed. For instance, your

MySQL select genres issue (php)

限于喜欢 提交于 2019-12-12 17:17:52
问题 I have a database: id | movie_name | genres 1 | Die Hard | Action, Thriller 2 | Gladiator | Adventure, Action, Drama, History 3 | Harry Potter and the Sorcerers Stone | Fantasy, Adventure, Family 4 | Pearl Harbor | Action, Melodrama, War 1) How I can select unique genres from genres of all database. I need the next: Action / Adventure / Drama / Family / Fantasy / History / Melodrama / Thriller / War 2) How can I see a movie of a certain genre? SELECT `movie_name` FROM `movies` WHERE `genre`

perl, dbi with sql statement with a like condition

梦想的初衷 提交于 2019-12-12 13:15:27
问题 in my code i must do a simple sql query with a like condition. i've do in this way my $out = "/Users/zero/out.log"; my $filename = "/Users/zero/data.txt"; my $dbh = DBI->connect("DBI:Oracle:sid=$sid;host=$host;port=$port", $user, $pwd) or die "Couldn't connect to database: " . DBI->errstr; my $query = "select SOMETHING from SOMETHING_1 where SOMETHING like ?||'%' "; my $sth = $dbh->prepare($query) or die "Connection Error: " . $dbh->errstr; open (IN,"< $filename") or die("Unable to open

mysql like to match complete word or beginning of word on string

依然范特西╮ 提交于 2019-12-12 12:13:58
问题 Given a search string I need to select every record where (in the field the search is performed on) there is at least one word that begins with the given text. For example: 'John Doe' Have to be be selected with search strings like: 'joh' 'do' 'JOHN doe' Have not to be selected with 'ohn' 'oe' I need (possibly) to avoid full text search. What I've found to work is $query = 'SELECT * FROM MYTABLE WHERE SEARCHFIELD LIKE "' . $searchText . '%"' . 'OR SEARCHFIELD LIKE "% ' . $searchText . '%"' I