472,145 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Insert ... Select...

I am new to mysql and would appreciate someone helping me out with this
converting this statement from postgresql to mysql.

INSERT INTO ossurjoinquestions SELECT *, RANDOM() as random_sort,
trunc(1144355460, 0) as instanceid FROM ossurcommonquestions WHERE tid =
'3';

So far I have

INSERT INTO ossurjoinquestions( tid, question, ans1, ans2, ans3, ans4, ans5,
corans, image_path, random_sort, instanceid )
SELECT tid, question, ans1, ans2, ans3, ans4, ans5, corans, image_path
FROM ossurcommonquestions
WHERE tid = '3'

What I am not sure how to do is add RAND() as random_sort or trunc($var,0)
as instanceid.

Thank you for any help.
Apr 6 '06 #1
1 1178
lifesciencemedia wrote:
What I am not sure how to do is add RAND() as random_sort or trunc($var,0)
as instanceid.


RAND() is the MySQL equivalent of PostgreSQL's RANDOM() function.
TRUNCATE() is the MySQL equivalent of PostgreSQL's TRUNC() function.

See the documentation on the respective web sites:
http://www.postgresql.org/docs/8.1/i...ions-math.html
http://dev.mysql.com/doc/refman/5.0/...functions.html

Regards,
Bill K.
Apr 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Philip Boonzaaier | last post: by
20 posts views Thread by Mark Harrison | last post: by
6 posts views Thread by lenygold via DBMonster.com | last post: by

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.