On Sun, 24 Nov 2013 16:10:58 +0000, "Joseph L. Casale"
<jcas...@activenetwerx.com> wrote:

>Hey guys,
>Trying to create a statement for use with parameters in a Python execute method
>when performing inserts with multiple nested selects. I can adjust it for use
>with Python, but I am having issues when there is more than one nested select.
>
>Something such as:
>
>INSERT OR IGNORE INTO table_a
>(
>    col_a,
>    col_b,
>    col_c,
>    col_d
>)
>SELECT col_a FROM (SELECT id FROM table_b WHERE name=?)
>,?
>,?
>,SELECT col_d FROM (SELECT id FROM table_c WHERE name=?);
>
>Anyone have a hint on how to perform such as query?

Perhaps:

INSERT OR IGNORE INTO table_a
(
    col_a,
    col_b,
    col_c,
    col_d
) VALUES (
         (SELECT id FROM table_b WHERE name=?)
        ,?
        ,?
        ,(SELECT id FROM table_c WHERE name=?)
);


>Thanks,
>jlc

HTH


-- 
Groet, Cordialement, Pozdrawiam, Regards,

Kees Nuyt

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to