Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Insert select
#1
Hi,

What is the process of inserting some records based on a select statement? I am using PyMySql.

An example or link to tutorial would be greatly appreciated.

Thanks in advance

Todd
Reply
#2
There is a syntax that allows for an update with a where clause that is a select instance.
[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table [ * ] [ [ AS ] alias ]
    SET { column = { expression | DEFAULT } |
          ( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
    [ FROM from_list ]
    [ WHERE condition | WHERE CURRENT OF cursor_name ]
    [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
The where clause can contain a query
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,252 Feb-14-2019, 08:34 PM
Last Post: woooee
  Insert using psycopg giving syntax error near "INSERT INTO" olgethorpe 4 15,665 Jul-21-2017, 07:39 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020