Jump to content

[SOLVED] sub query syntax error!


Adam

Recommended Posts

Hi guys.

 

MySQL is certainly not my strongest point! I have a problem in the syntax of this query:

 

delete from auth_user_temp aut
where aut.user_id in (
    select user_id from user_group
    where (userclass_id = 25 or userclass_id = 6)
    group by user_id
    having count(userclass_id) = 2
);

 

Basically the sub query returns records that have the userclass_id of 25 or 2, nothing else, and no less. The select sub query works fine by itself. I think the problem is using "aut.user_id in ..."

 

Does any body have an alternative or, perhaps be able to tell me why it's not working?

 

Thanks!

Adam

 

 

Link to comment
Share on other sites

It's the same?

 

delete from auth_user_temp aut
where aut.user_id in (
    select user_id from user_group
    where (userclass_id = 25 or userclass_id = 6)
    group by user_id
    having count(userclass_id) = 2
);

 

Returns:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where aut.user_id in (

    select user_id from user_group

    where (userclass_i' at line 2

 

Cheers,

Adam

Link to comment
Share on other sites

.. 4.1 currently but we're planning to upgrade soon. I'd still like to know if anyone has any suggestions as to why that wouldn't work, but I have made a work around in PHP to solve my problem now.

 

Thanks,

Adam

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.