Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-02-2007, 10:59 AM   #1
FFMG
 
FFMG's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Moving data from one table to another, (existing), one.


Hi,

I have a table, TABLEA ( ROWA[int], ROWB[int] ) and I want to move all
the data to another table, TABLEB ( ROWA[int], ROWB[string],
ROWC[string] )

ROWC will be a constant string but ROWB will be converted to a string
(VARCHAR 255) of the current INT value.

How would you move the data from A to B?

INSERT INTO TABLEB (
ROWA,
ROWB,
ROWC
)
VALUES
(
SELECT ROWA, ROWB FROM TABLEA,
'ROWC'.... )

Not sure how that would work.

Thanks

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=17868

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 07-02-2007, 10:59 AM   #2
Captain Paralytic
 
Captain Paralytic's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Moving data from one table to another, (existing), one.

On 27 Jun, 06:31, FFMG <FFMG.2st...@no-mx.httppoint.com> wrote:
> Hi,
>
> I have a table, TABLEA ( ROWA[int], ROWB[int] ) and I want to move all
> the data to another table, TABLEB ( ROWA[int], ROWB[string],
> ROWC[string] )
>
> ROWC will be a constant string but ROWB will be converted to a string
> (VARCHAR 255) of the current INT value.
>
> How would you move the data from A to B?
>
> INSERT INTO TABLEB (
> ROWA,
> ROWB,
> ROWC
> )
> VALUES
> (
> SELECT ROWA, ROWB FROM TABLEA,
> 'ROWC'.... )
>
> Not sure how that would work.
>
> Thanks
>
> FFMG
>
> --
>
> 'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
> (http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
> (http://www.insurance-owl.com/other/car_rec.php)
> 'Free URL redirection service' (http://urlkick.com/)
> ------------------------------------------------------------------------
> FFMG's Profile:http://www.httppoint.com/member.php?userid=580
> View this thread:http://www.httppoint.com/showthread.php?t=17868
>
> Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).


I assume you actually mean COLA, COLB, COLC as you are talking about
columns and not rows.
You also have to use the correct sytax as shown in the manual for
INSERT ... SELECT
http://dev.mysql.com/doc/refman/5.0/en/insert.html

You would write it like this:

INSERT INTO TABLEB (
ROWA,
ROWB,
ROWC
)
SELECT ROWA, ROWB, 'ROWC' FROM TABLEA

OR more correctly conceptwise:

INSERT INTO TABLEB (
COLA,
COLB,
COLC
)
SELECT COLA, COLB, 'COLC' FROM TABLEA

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-02-2007, 10:59 AM   #3
FFMG
 
FFMG's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Moving data from one table to another, (existing), one.


Captain Paralytic;78563 Wrote:
>
> ...
> INSERT INTO TABLEB (
> COLA,
> COLB,
> COLC
> )
> SELECT COLA, COLB, 'COLC' FROM TABLEA


Thanks, you are right I was talking about COLA/B/C

I just want to make sure that COLB will not be a problem as I am
inserting an INT into a VARCHAR(255). I don't need to convert
anything?

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=17868

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-02-2007, 10:59 AM   #4
Paul Lautman
 
Paul Lautman's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Moving data from one table to another, (existing), one.

FFMG wrote:
> Captain Paralytic;78563 Wrote:
>>
>> ...
>> INSERT INTO TABLEB (
>> COLA,
>> COLB,
>> COLC
>> )
>> SELECT COLA, COLB, 'COLC' FROM TABLEA

>
> Thanks, you are right I was talking about COLA/B/C
>
> I just want to make sure that COLB will not be a problem as I am
> inserting an INT into a VARCHAR(255). I don't need to convert
> anything?
>
> FFMG


I always find the best way to be sure of these things is to knock up test
tables and try it out!


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-02-2007, 11:00 AM   #5
FFMG
 
FFMG's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Moving data from one table to another, (existing), one.


Paul Lautman;78676 Wrote:
> FFMG wrote:
> > Captain Paralytic;78563 Wrote:
> >>
> >> ...
> >> INSERT INTO TABLEB (
> >> COLA,
> >> COLB,
> >> COLC
> >> )
> >> SELECT COLA, COLB, 'COLC' FROM TABLEA

> >
> > Thanks, you are right I was talking about COLA/B/C
> >
> > I just want to make sure that COLB will not be a problem as I am
> > inserting an INT into a VARCHAR(255). I don't need to convert
> > anything?
> >
> > FFMG

>
> I always find the best way to be sure of these things is to knock up
> test
> tables and try it out!


Yes, that's what I did, and it does work.

But my question was kind of 'best practice'.

Because I am sure that moving a float to a string might cause some
problems.
(Just guessing here).

It might work, but is it the right way?

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
(http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php)
'Free URL redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=17868

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-02-2007, 11:00 AM   #6
Captain Paralytic
 
Captain Paralytic's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Moving data from one table to another, (existing), one.

On 28 Jun, 06:15, FFMG <FFMG.2sv...@no-mx.httppoint.com> wrote:
> Paul Lautman;78676 Wrote:
>
>
>
>
>
> > FFMG wrote:
> > > Captain Paralytic;78563 Wrote:

>
> > >> ...
> > >> INSERT INTO TABLEB (
> > >> COLA,
> > >> COLB,
> > >> COLC
> > >> )
> > >> SELECT COLA, COLB, 'COLC' FROM TABLEA

>
> > > Thanks, you are right I was talking about COLA/B/C

>
> > > I just want to make sure that COLB will not be a problem as I am
> > > inserting an INT into a VARCHAR(255). I don't need to convert
> > > anything?

>
> > > FFMG

>
> > I always find the best way to be sure of these things is to knock up
> > test
> > tables and try it out!

>
> Yes, that's what I did, and it does work.
>
> But my question was kind of 'best practice'.
>
> Because I am sure that moving a float to a string might cause some
> problems.
> (Just guessing here).
>
> It might work, but is it the right way?
>
> FFMG
>
> --
>
> 'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
> (http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
> (http://www.insurance-owl.com/other/car_rec.php)
> 'Free URL redirection service' (http://urlkick.com/)
> ------------------------------------------------------------------------
> FFMG's Profile:http://www.httppoint.com/member.php?userid=580
> View this thread:http://www.httppoint.com/showthread.php?t=17868
>
> Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).- Hide quoted text -
>
> - Show quoted text -


The "right" way I guess is to use a CAST function and some SQL
implementations may require you to do this. MySQL however will handle
the casting for you.

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying Table Data For Archive GA Database 3 07-02-2007 10:58 AM
table name as data Rob Kings Database 7 07-01-2007 6:27 PM
How to take data out of table, restructure the table and then put the data back in Laphan Database 4 07-01-2007 6:24 PM
Random Script thought By Jon - Gzipped table data news.cableregina.com PHP 0 07-01-2007 5:25 PM
MP3 player into existing Car Stereo buffyslay@gmail.com Car audio 0 06-18-2007 1:40 PM


Featured Websites




All times are GMT +1. The time now is 3:43 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98