473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Please help - urgent request - I need a query like below ASAP

Expand|Select|Wrap|Line Numbers
  1. UPDATE redesign.student SET student_work_area_other SELECT
  2. REPLACE('anywhere,(.*)', '$1', i.work_area) AS regexp_col FROM
  3. mycompany.interns i, redesign.student s WHERE i.unique_key =
  4. s.unique_key GROUP BY work_area
  5.  
Of course this does not work, but I have no idea what the MySQL
equivalent will be to something like this.

I basically want to take out PART of a column field value and update it
into another database table. How is that done?

Thanx
Phil

Jan 30 '06 #1
4 1557
<ph**************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Expand|Select|Wrap|Line Numbers
  1.  UPDATE redesign.student SET student_work_area_other SELECT
  2.  REPLACE('anywhere,(.*)', '$1', i.work_area) AS regexp_col FROM
  3.  mycompany.interns i, redesign.student s WHERE i.unique_key =
  4.  s.unique_key GROUP BY work_area
  5.  

Of course this does not work, but I have no idea what the MySQL
equivalent will be to something like this.


UPDATE redesign.student AS s, mycompany.interns AS i
SET s.student_work_area_other = REPLACE(i.work_area, 'anywhere,', '')
WHERE i.unique_key = s.unique_key

You had the order of arguments wrong in the REPLACE function. Also, REPLACE
doesn't understand regular expressions or positional parameters; it only
does fixed strings. But in this case the change you need to make can be
done with fixed strings.

I can't tell what your GROUP BY is intended to do in this query. It seems
irrelevant.

Regards,
Bill K.
Jan 30 '06 #2
See below, thanx

Bill Karwin wrote:
<ph**************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Expand|Select|Wrap|Line Numbers
  1.  > UPDATE redesign.student SET student_work_area_other SELECT
  2.  > REPLACE('anywhere,(.*)', '$1', i.work_area) AS regexp_col FROM
  3.  > mycompany.interns i, redesign.student s WHERE i.unique_key =
  4.  > s.unique_key GROUP BY work_area
  5.  > 

Of course this does not work, but I have no idea what the MySQL
equivalent will be to something like this.
UPDATE redesign.student AS s, mycompany.interns AS i
SET s.student_work_area_other = REPLACE(i.work_area, 'anywhere,', '')
WHERE i.unique_key = s.unique_key

You had the order of arguments wrong in the REPLACE function. Also, REPLACE
doesn't understand regular expressions or positional parameters; it only
does fixed strings. But in this case the change you need to make can be
done with fixed strings.


I can't see how, because I need the content after the word "anywhere",
and NONE of the conent up to and including "anywhere"; how can a fixed
string REPLACE do that?
I can't tell what your GROUP BY is intended to do in this query. It seems
irrelevant.

Regards,
Bill K.


Jan 30 '06 #3
<ph**************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I need the content after the word "anywhere",
and NONE of the conent up to and including "anywhere"; how can a fixed
string REPLACE do that?


Aha - I didn't understand the requirements from your nonsense code above.

Well, perhaps you'll have to get more creative.
There are many functions available to you in MySQL.
LOCATE and SUBSTRING are a couple of good ones.
See http://dev.mysql.com/doc/refman/5.0/...functions.html

I'll leave it to you to figure out how to utilize them in this case. I
think it's a bad idea for you to take examples from newsgroup postings and
run them without understanding them.

Good luck,
Bill K.
Jan 30 '06 #4
Thanks to you and another DBA (Sybase DBA), this one got solved (I
couldn't have come up with this one to save my life):

update student_db.student s
set s.application_area_other = (
select SUBSTRING(i.application_area, LOCATE('anywhere',
i.application_area) + LENGTH('anywhere') + 2) as regexp_col
from olddb.applicant i
where s.unique_key = i.unique_key
)

Phil

Bill Karwin wrote:
<ph**************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I need the content after the word "anywhere",
and NONE of the conent up to and including "anywhere"; how can a fixed
string REPLACE do that?


Aha - I didn't understand the requirements from your nonsense code above.

Well, perhaps you'll have to get more creative.
There are many functions available to you in MySQL.
LOCATE and SUBSTRING are a couple of good ones.
See http://dev.mysql.com/doc/refman/5.0/...functions.html

I'll leave it to you to figure out how to utilize them in this case. I
think it's a bad idea for you to take examples from newsgroup postings and
run them without understanding them.

Good luck,
Bill K.


Jan 31 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Peter | last post by:
My problem is the last bit of coding below, the like statement does not work. what I have is a product options field and in it is stored characters i.e. "avcy" etc what the query does is...
1
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to...
1
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to...
7
by: phillip.s.powell | last post by:
Now I have another SQL query for MySQL I can't figure out!! This is overwhelming me completely and I also must have this figured out today and I can't figure it out!! UPDATE student_db.student...
8
by: John Austin | last post by:
I need to understand why if I add a control and use AddHandler to connect its click event, it will work in Page_Load, but not in a Button_Click. The idea is that the user types some data, presses...
2
by: archana | last post by:
Hi all, I want to send webrquest throguh anonymous proxy. Can anyone tell me how to validate ip address and port number of anonynmous proxy server. Is it using TctpClient class ? And...
2
by: JHNielson | last post by:
I Know I've posted an Urgent message before. But I'm in the middle of system testing, and these little stupid bugs are killing me...... I have a query that checks that a set of values (the...
3
by: jats | last post by:
I am a .NET programmer and i had recently got a web application designed in Classic ASP, to make some modifications. When i run the application and try to create a new user the following error...
11
by: Hamayun Khan | last post by:
HI All My client requirements are such that I m going to generate query runtime in asp.net. At some time the query reaches to very much length as below SELECT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.