Irish SEO,  Marketing & Webmaster Discussion

 

MySql gurus

This is a discussion on MySql gurus within the Coding Help forums, part of the Webmaster Help category; Ok all mysql gurus, I need help here. I have a table with few fields: f_1, f_2, f_3, f_4 I ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Members List Calendar Search Today's Posts Mark Forums Read


Notices

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 16-11-2006, 09:13 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default MySql gurus

Ok all mysql gurus, I need help here.

I have a table with few fields:

f_1, f_2, f_3, f_4

I want to run a query in mysql to get all the fields together and update the result into f_1

Update `table` set `f_1`=`f_1`. " ".`f_2`." ".`f_3`." ". `f_4`

is this possible directly on the server using Navicat?
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Directory Submission Directory Submission
:. News & Press Release Ireland GiveItSocks.com
:. Used Cars Ireland, Car Parts & Car Audio Cars For Sale, Car Parts & Accessories
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 16-11-2006, 09:23 PM
jmcc's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Posts: 298
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
jmcc has a spectacular aura about
Default

Quote:
Originally Posted by louie View Post
Ok all mysql gurus, I need help here.

I have a table with few fields:

f_1, f_2, f_3, f_4

I want to run a query in mysql to get all the fields together and update the result into f_1

Update `table` set `f_1`=`f_1`. " ".`f_2`." ".`f_3`." ". `f_4`

is this possible directly on the server using Navicat?
Not sure about Navicat but look at the CONCAT command.

MySQL AB :: MySQL 5.0 Reference Manual :: 13.2.7 SELECT Syntax

Regards...jmcc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 16-11-2006, 09:29 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

I was looking at that but it only does it on SELECT statement.
I love to do it directly to the database table instead runing the code in PHP, just in case I get an error and everything goes busted.
php will do if I can not run it on the table itself
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 16-11-2006, 09:42 PM
jmcc's Avatar
Wannabe Geek
 
Join Date: Feb 2006
Posts: 298
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
jmcc has a spectacular aura about
Default

Quote:
Originally Posted by louie View Post
I was looking at that but it only does it on SELECT statement.
I love to do it directly to the database table instead runing the code in PHP, just in case I get an error and everything goes busted.
php will do if I can not run it on the table itself
Create a temporary table and use INSERT INTO temp_table(f1) SELECT CONCAT(t1.f1,',',t1.f2 etc). Then just replace t1.f1 with the data from temp_tab.

I'm not sure if the UPDATE t1 SET f1=CONCAT(f1,f2,f3,f4) would work cleanly. It might be best to test it on a local setup first before deploying it using php. Backup the tables first though.

Regards...jmcc
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 16-11-2006, 09:47 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

I will try that after dinner or in the morning.
Never thought of creating a new table.
The table is duplicate of the original, so i could play with it alright. I also have an xml and xsl copy just in case.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 16-11-2006, 10:00 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,007
Nominated 5 Times in 3 Posts
TOTW/F/M Award(s): 0
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

Thanks man.
It worked on the server using Navicat:
Code:
UPDATE `tbl_products` SET `product_name`= CONCAT(`product_name`, ' ', `product_desc`, ' - ', `code_no`, ' ', `group`)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
gurus, mysql

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
calender script (php, mysql) 7aken Coding Help 3 20-10-2006 06:57 AM
php, mysql & .asp from same laptop alex Server / Technical Administration Tips and Queries 11 16-10-2006 06:01 PM
What MySQL front end GUI do you use (windows) louie Webmaster Discussion 3 02-10-2006 01:06 PM


All times are GMT +1. The time now is 09:27 PM.


Powered by: vBulletin Version 3.7.3, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.2.0