Richard, it's possible, & your syntax is pretty close.

Try this:

INSERT INTO info_stamp
(fav_colour, hobby, stamp_date, firstname,
last_name, sexe, age, username, email, insc_date)
SELECT  $fav_colour, $hobby, $time, a.firstname, a.last_name, a.sexe,
a.age, a.username, b.email, b.inscription_date
FROM mem_info a
JOIN mem_login b ON a.username = b.username
WHERE a.username = $username;

I removed the reference to the 'key' column, fyi.

More info here: http://dev.mysql.com/doc/refman/5.0/en/insert-select.html

Hope this helps!

-Dan



On Feb 17, 2008 9:09 PM, Richard <[EMAIL PROTECTED]> wrote:

> Hello,
>
> I need to insert one entry(one line) containing 10 values, some from a
> form(ok) but some from two other tables, what is the best way to do this ?
>
> Say for example I need to enter this information :
>
> first_name - last_name - age - sexe - username - email - favorite_colour
> - hobby - inscription_date - timestamp
>
>
> I already have a table containing : firstname - last_name - sexe - age -
> username
> And another one containing: username - email - inscription_date
>
> And I get from the member : favorite_colour - hobby
>
> Out of these three sources I would like to insert into one table
> containing all of these details.
>
> I need this to make a print of one moment So I would be able to pull out
> an entry saying : At this date the information was the following :
>
> first_name - last_name - age - sexe : height - username - email -
> favorite_colour - hobby - inscription_date - timestamp
>
>
> Can I do something like this :
>
> INSERT INTO info_stamp (key , fav_colour, hobby, stamp_date, firstname,
> last_name, sexe, age, username, email, insc_date )VALUES ('',
> $fav_colour, $hobby, $time, (SELECT  a.firstname, a.last_name, a.sexe,
> a.age, a.username, b.email, b.inscription_date FROM mem_info a JOIN
> mem_login b ON a.username = b.username WHERE a.username = $username));
>
> I guess this query would not actually work, what would be the corect way
> to do this ?
>
> Thanks in advance :)
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>

Reply via email to