Update a portion of text in a field
Hello mysql, Something I have been thinking about without any clue on how I can achieve it. I know how to update a field with "update table X set field1='My Text' where tableid = 1" Now, say I have in a table X, the field1 with the value : 'I have been searching that functionalities for several days' and I would like to replace 'functionalities' by 'functionality' Would anyone knows how to replace JUST one word or a part of a text in a field without using an external program ? Please advise, thanks Best regards, Jacques Jocelyn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re[2]: Update a portion of text in a field
Hello Daniel, DK> MySQL has a 'replace' function for this: DK> update table X set field1=replace(field1, 'functionalities', DK> 'functionality') where tableid=1; DK> http://dev.mysql.com/doc/mysql/en/String_functions.html Awesome ! Got it, thanks Best regards, Jacques Jocelyn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: merging of two tables using temp tables???
Hello bruce, Wednesday, September 29, 2004, 6:57:34 AM, you wrote: b> hi b> i'd like to be able to merge/combine the two tables so that i get b> +--+--++--+---+-+ b> | ID | type | status | user | ID| uID | b> +--+--++--+---+-+ b> | 40 |1 | 0 | b> | 40 |2 | 0 | . b> | 40 |3 | 0 | . b> | 40 |4 | 0 | ... b> with the appropriate information in the various columns/rows... b> i'm looking to be able to fill the resulting table with the information if b> it's present, or to have nulls/'0' where the information isn't available... I was about to say it's easy ;-) then I saw your ps section :-o anyway, the idea I had may give a way to start : insert NEW_TABLE(ID,type,status,user,ID,uID) select ID,type,status,user,ID,uID from table1 left join table2 on ... where ... hope that helps. Best regards, Jacques Jocelyn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Optimize queries
Hello there, Until I had query time restriction due to my web hoster. Meaning whenever the query was too long, it gets killed ! Now I have changed my webhoster, I'd like to optimize my queries and I would like to have your opinion on that. I wrote multiple queries to prevent any long query time duration such as : until now I did the following - to obtain the total of item which match requirements -> select count(*) 'bigTotal' from table where field1='myvalue' then I selected total of category from the same table to get the percentage of the total such as : -> select count(*) 'categoryTotal' from table where category1='myvalue' and from a script I calculated my percentage = bigToal/categoryTotal -> select count(*) 'categoryTotal' from table where category2='myvalue' and from a script I calculated my percentage = bigToal/categoryTotal etc.. now, I have planned the following : create ONE query to do all this. is there a way then to merge the two previous queries in only one ? and calculate the percentage at the same time ? To merge all my category queries, I can use a GROUP BY, but what about the bigTotal, can have that in the same query ? Please advise. Thanks Best regards, Jacques Jocelyn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re[2]: Optimize queries
Hello Dobromir, Friday, October 8, 2004, 3:47:06 PM, you wrote: DV> Hi, DV> Using sub-selects (MySQL 4.1 and higher) you can use something like DV> select count(*)/(select count(*) from table where field1='myvalue') as DV> percentage from table where category='myvalue' group by category; DV> but I don't think you will gain much in performance this way. I'd rather use DV> two queries - one for the total and one for the percentages. If field1 is DV> indexed DV> select count(*) from table where field1='myvalue' DV> should be quite fast, so I don't think you should worry about having an DV> additional query. You may be right. I was just wondering, thanks for the input. I will go for two queries. thanks Best regards, Jacques Jocelyn -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]