I’ve got a problem and hope you can help me find a solution.
Name Hours title
Name1 12 #1 (Text) - text - text
Name2 13 #1545 (text) - text - text
Name5 19 #33558 (text) - text - text
Name6 36 #54123 (text) – text
This is an extract from following query:
SELECT name AS Name, Sum((Unix_Timestamp(end)-Unix_Timestamp(start))/3600) AS Hours, title
FROM myTable
GROUP BY title;
Well, we've got a column with names, a column called Hours(how many hours did a name spend on sth.?) and a column called title(the title of sth.). The title of sth. includes #, a number and text.
Is it possible to only get the number of the title? Like:
Name Hours title
Name1 12 1
Name2 13 1545
Name5 19 33558
Name6 36 54123
I'm stuck because the number length varies. I don't know whether there is a function just calling everything before the first space if the title contains a number.
I need it to compare the title with a csv-file.
Your help will be much appreciated.
Soloco
EDIT
There is always a space after #.
Edit2:My bad, # has to be eliminated 2.
enter code hereTry this –
In your case, the query will be –
This works only if you have spaces and other text follwing your
#<number>USE LOCATE instead of Charindex for mysql –
http://www.overclock.net/web-coding/450373-mysql-query-help.html