Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006
    Posts
    7

    Unanswered: Dynamic Insert Query

    Hi there,

    I have been wondering why the following query doesn't work in PostgreSQL:

    insert into store_to_storecatagory
    values (select distinct storeid from store where store ILIKE 'Art etc',
    select distinct storecatagoryid from storecatagory where
    storecatagory ILIKE 'ARTS AND CURIOS');

    The response I get is:
    ERROR: syntax error at or near "select" at character 44

    I know that the SELECT statements work fine. But I am not sure that they can be combined with an INSERT statement...


    Your help is always appreciated. Thanks and best wishes,
    (sorry about posting this on the MySQL forum previousely).

  2. #2
    Join Date
    Jan 2006
    Posts
    7
    Hi, I found my solution with the help of a friend:

    insert into store_to_storecatagory (storeid, storecatagoryid) (select distinct storeid, storecatagoryid from store, storecatagory where store ILIKE 'Art etc%' and storecatagory ILIKE 'ARTS AND CURIOS')


    Hope this helps someone else.


    Ciao.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •