Forum Moderators: open

Message Too Old, No Replies

How do i select cid, title, url, and insert afterwards?

         

john1000

4:15 pm on Aug 12, 2006 (gmt 0)

10+ Year Member



hello,

im still busy to save my site and my major problem is how to select my downloads..(based on category) and dump it into the new table...

if i do this......

SELECT cid, title, url, description FROM old_downloads
shows everything but i realy want to select only cid 36 .
(that means category 36)

how do i dump it directly into another table?
and does the table with rows need to have the same name?

does this makes any sense?

smatts9

10:14 pm on Aug 13, 2006 (gmt 0)

10+ Year Member




SELECT cid, title, url, description FROM old_downloads
shows everything but i realy want to select only cid 36 .
(that means category 36)

how do i dump it directly into another table?

SELECT cid, title, url, description FROM old_downloads WHERE cid='36'

john1000

10:39 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



thanks smatts9,

that works indeed...
but its not clear how i can make /get a dump to insert it....
imagine that it needs to go into a new table with same 4 or 5 rows..
how do i do that...?

cause if i use :

SELECT cid, title, url, description
FROM old_downloads
WHERE cid = '36'

i would like to INSERT it into a new table...

directrix

10:46 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



You could do:

INSERT INTO new_downloads SELECT cid, title, url, description FROM old_downloads where cid = 36

This assumes that table new_downloads contains four fields that match cid, title, url, description in type, and preferably also in length. The field names don't need to be the same. This works on version 5.0.15 of MySQL.

john1000

10:52 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



well im on 4.0.27-standard but i guess i can try....
thanks...
i have to try something....
hate to loose 2100 downloads..

john1000

11:04 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



hello...

i just forgot something...
i cannot insert it like this cause the new table has a cat id to...
so if i use..

INSERT INTO old_downloads SELECT cid, title, url, description FROM old_downloads where cid = 36

it inserts without defining the catid...
for example...the catid i would insert it in...would be 105.
how do i solve this..?

directrix

11:39 pm on Aug 13, 2006 (gmt 0)

10+ Year Member



You should be able to insert it as a constant. Assuming catid is the fifth field in new_downloads:

INSERT INTO new_downloads SELECT cid, title, url, description, 105 FROM old_downloads where cid = 36

john1000

12:23 am on Aug 14, 2006 (gmt 0)

10+ Year Member



@ directrix ,ive send you a pm...

directrix

6:05 pm on Aug 14, 2006 (gmt 0)

10+ Year Member



@ directrix ,ive send you a pm..

Can't answer at the moment, suggest you google php sql scripts or similar.