1

hi i have problem on my mysql query i wanna insert result of joined select query and another data

this is my query check and advise me please

    INSERT INTO TB_AUTO_BAN
    (MEMO,
    REG_DATE,
    USER_ID,
    NAME,
    PHONE_NUM
    )
    VALUES(
    'test',
    NOW(),
    SELECT
    a.USER_ID, a.NAME, a.CONTACT_NUM
    FROM TB_CONTACT AS a INNER JOIN TB_CONTACT_GROUP AS b 
    ON a.GROUP_CONTACT_SEQ = b.GROUP_CONTACT_SEQ 
    WHERE b.USER_ID= '[email protected]' AND b.GROUP_CONTACT_SEQ = 12000)
0

1 Answer 1

4

The correct syntax is as below

  INSERT INTO TB_AUTO_BAN
    (MEMO,
    REG_DATE,
    USER_ID,
    NAME,
    PHONE_NUM
    )

    SELECT 
    'test',NOW(),
    a.USER_ID, a.NAME, a.CONTACT_NUM
    FROM TB_CONTACT AS a INNER JOIN TB_CONTACT_GROUP AS b 
    ON a.GROUP_CONTACT_SEQ = b.GROUP_CONTACT_SEQ 
    WHERE b.USER_ID= '[email protected]' AND b.GROUP_CONTACT_SEQ = 12000
Sign up to request clarification or add additional context in comments.

1 Comment

forgot to remove the last bracket at end of select query..check edit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.