How do i remove a "#" sign from a ms-access hyperlink field? - ms-access

In a msaccess field you see an hyperlink f.e. https://stackoverflow.com when is open the field using F2 i see #https://stackoverflow.com#. How do i remove the # using an update query? Even selection query is hard
I tried the "Like" parameter but Like "#" dus not give any hits. I tried also ""#"" and "'#'" and ''#'' but no succes whatsoever.
no errors but also not the wanted result

You can select records containing the hash/pound symbol (#) using the like pattern *[#]* e.g.:
select * from YourTable where YourTable.YourField like "*[#]*"
You can remove the hash/pound symbol (#) from the values held by such records using the replace function, e.g.:
update YourTable
set YourTable.YourField = Replace(YourTable.YourField,"#","")
where YourTable.YourField like "*[#]*"
To remove the symbol from only the ends of the string, since URLs cannot contain spaces, you could use the following:
update YourTable
set YourTable.YourField = Trim(Replace(Replace(" " & YourTable.YourField & " "," #",""),"# ",""))
where YourTable.YourField like "[#]*" or YourTable.YourField like "*[#]"

A hash sign # in a text string in MS Access can be found in a search (and from there replaced) by wrapping it in square brackets, i.e. [#]

Related

MySQL query LIKE %...% query returning other results?

So I'm trying to code a PHP script, but we'll just leave it at the SQL part of things since this is where the issue is arising. I've a SELECT * query which should only grab from the rows where the user ID matches, and the badge ID meets their userID followed by an underscore. Although, it's grabbing results that shouldn't be included?
Here's my SQL query:
SELECT *
FROM `user_badges`
WHERE `user_id` = 1
AND `badge_id` LIKE '%1_%'
That should only return badges that start/contain 1_, it is grabbing all the badges that do contain/start with 1_ but it's also grabbing it215. If I search a different user ID, for example my own, it will grab all the badges with 3_ AND it's also grabbing ACH_RoomDecoFurniCount31 which is confusing because it doesn't contain 3_. Maybe there's more to it? Could someone please point me in the right direction.
You need to escape the _ as it's a wildcard character. Your query would should be like this:
SELECT *
FROM `user_badges`
WHERE `user_id` = 1
AND `badge_id` LIKE '%1\_%'
_ is also a wildcard in SQL - A substitute for a single character
_ is also a wildcard character. It means "any single character" (whereas % is "any sequence of characters").
You could escape/quote that _ or use the LOCATE function instead of a pattern match.
WHERE badge_id LIKE '%1\_%'
WHERE locate('1_', badge_id) > 0
_ is a wildcard "_ matches exactly one character." so what you are saying is:
% : starts with anything(or nothing)
1: contains 1
_: has exactly 1 of % (or anything, or nothing)
http://dev.mysql.com/doc/refman/5.7/en/string-comparison-functions.html

MYSQL check if field contains symbol and remove

I've a MySql table with columns containing 3 symbols (dollar: US$, £ and ?).
I'm using PHP (in Codeigniter) to remove all of the symbols, like this:
$replace = $this->db->query("UPDATE wm_rendiconti_amazon
SET Royalty_USD = SUBSTRING(Royalty_USD, 5),
Royalty_GBP = SUBSTRING(Royalty_GBP, 3),
Royalty_EUR = SUBSTRING(Royalty_EUR, 3)");
This basically removes the symbols with the use of SUBSTRING.
The problem I'm trying to solve is to not cut out the numbers in case the action get run twice (which will remove again 3/5 characters).
I'd like to check with mysql "If the field contains the symbol US$ or £ or ? then remove it".
Is this possible with mysql query?
You could better use MySQL REPLACE function. The set function can be something like
field_name = REPLACE(field_name, "$ ", "") /*replace with $ with empty string */

Replace spaces with dash and copy into new column

I have table named "city" with column named "city_name" with about 200 records.
I have created another colum named slugs where I want to copy all the records from "city_name" in the same row with spaces replaced with dash - and lowercase.
How can I achieve this via phpmyadmin.
Thanks
You should be able to do this via the following query:
UPDATE city SET slugs=LOWER(REPLACE(city_name, " ", "-"))
Breaking this down, we're using REPLACE to swap all instances of " " with "-" in the existing city_name column, and then passing the result of this to the LOWER function (to convert the data to lower case) before setting the slugs field with this value.
Depending on how "clean" your data is, you might also want to TRIM the data (to remove any leading or trailing spaces in the city_name field) before you apply the REPLACE as such:
UPDATE city SET slugs=LOWER(REPLACE(TRIM(city_name), " ", "-"))
Incidentally, if you've not used (My)SQL much I'd recommend a read of the String Functions manual page - the time you spend on this now will more than repay itself in the future.
Here is SQLFiddle
MYSql documentation for function LOWER(str) and REPLACE(str,from_str,to_str)
UPDATE city SET slugs = LOWER(REPLACE(city_name," ", "-"));

removing characters from field in MS Access database table

Using MS Access 2010.
I have a field in a table that contains windows path names surrounded by quotes, like this
"C:\My Documents\Photos\img1.jpg"
"C:\My Documents\Photos\products\gizmo.jpg"
"C:\My Documents\Photos\img5.jpg"
and so on.
I need to get rid of the quotes so the column looks like this:
C:\My Documents\Photos\img1.jpg
C:\My Documents\Photos\products\gizmo.jpg
C:\My Documents\Photos\img5.jpg
Is there a way to write an update query to do this?
OR a better way to do it altogether?
If you will be doing this from within an Access session, using Access 2000 or later, you can use the Replace() function in an update query to remove the quotes. Remove would mean replace them with an empty string.
UPDATE YourTable
SET path_field = Replace(path_field, '"', '');
If any of those path strings could include quotes within them (yuck!), consider the Mid() function ... ask it to start at the 2nd character (skipping the lead quote), and return the number of characters equivalent to Len(path_field) - 2
UPDATE YourTable
SET path_field = Mid(path_field, 2, Len(path_field) - 2);
Either way, you may want to include a WHERE clause to ignore rows without path_field values.
WHERE Len(path_field) > 0
And if you must do this again when new data is added, use a different WHERE clause to ensure you UPDATE only those rows whose path_field values start and end with quotes.
WHERE path_field Like '"*"'
That was using the * wild card for Access' default ANSI 89 mode. If you will do this from ADO (ANSI 92 mode), use the % wild card.
WHERE path_field Like '"%"'
... or use ALike and the % wild card with either mode.
WHERE path_field ALike '"%"'
The solution with REPLACE already mentioned by others works, but removes ALL quotes, even if they are in the middle of the string.
If you only want to remove quotes at the beginning or at the end, but leave quotes in the middle of the string as they are, you can do it with the following two queries:
Remove first character if it's a quote:
update YourTable
set YourField = right(YourField, len(YourField) - 1)
where left(YourField, 1) = '"'
Remove last character if it's a quote:
update YourTable
set YourTable = left(YourField, len(YourField) - 1)
where right(YourField, 1) = '"'
To make this a permanent change, you might run an update query that looked something like this:
UPDATE [Your Table]
SET [Your Table].[Your Field] = Replace([Your Table].[Your Field],"""","")
This will get rid of all quotes, even if they aren't at the beginning or end. Post back if that's not exactly what you want.
Assuming your column name is MyColumn and table name is MyTable, you can use this sql to update your data to get rid of quotes.
UPDATE MyTable
SET MyColumn = REPLACE(MyColumn,'"','')

Doing partial match on name fields in SQL Server

I need to enable partial matching on name search. Currently it works with Like '%#name%' but it's not good enough.
We need to enable typing in both first name and last name and both need to be partial, so I'm assuming full text is the way to go.
The problem is that I can't get it do a partial match on a name. For example searching for my name (Fedor Hajdu) will work if I type in either parts in full but not partial (It should match a search for 'fe ha' for example.
How can I achieve this? Can fulltext index be set to do something like syllable matching?
humm three options that mya help you:
the INFLECTIONAL form (Link)
CONTAINS with NEAR (Link)
CONTAINS with Weighted Values (Link)
If that doesn't help, get the string 'fe ha' and add a '%' on every blank space and do a Like:
Like '%fe%ha%'
Using CONTAINS() or CONTAINSTABLE() all you need to do is add * at the end of your matching string:
CONTAINS (Description, '"top*"' );
If you have your string as a parameter you may concatenate like this:
SET #SearchTerm = '"' + #NameParameter + '*"'
CONTAINS (Description, SearchTerm );
https://technet.microsoft.com/en-us/library/ms142492(v=sql.105).aspx