Jump to content

Recommended Posts

Hello Freaks!

 

First time poster, long time reader.

 

I'm making a simple standalone blog extension in mediawiki for work and am getting KILLED trying to use the IN() condition. Fighting with it recently actually made me realize I've never actually gotten one work before. EVER! I usually end up using a loop to build an outrageous looking bunch of OR's into a query string to get around it. This madness has to stop.

 

I've done everything I can think of to tweak the syntax. I still get query errors. Can anyone see what I'm doing wrong? From what I can see, I'm following the usage perfectly!

 

I have a  table called simpleblog_perms looking something like this:

 

id (INT)  group (TEXT)  logid (INT)  perm (TEXT)

---------  ---------------    ------------  ------

1            Staff              1                R

2            sysop            1                W

 

The following queries all result in an error!

 

SELECT * FROM simpleblog_perms WHERE group IN (Staff,bureaucrat,sysop)

SELECT * FROM simpleblog_perms WHERE group IN (Staff, bureaucrat, sysop)

SELECT * FROM simpleblog_perms WHERE group IN ('Staff','bureaucrat','sysop')

SELECT * FROM simpleblog_perms WHERE group IN ('Staff', 'bureaucrat', 'sysop')

SELECT * FROM simpleblog_perms WHERE (group IN ('Staff','bureaucrat','sysop'))

 

They each return something like  MySQL returned error "1064: 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 'group IN ('Staff','bureaucrat','sysop')' at line 2 (localhost)".

 

I'm using MySQL 5.1.30 with PHP  5.2.9-2

Link to comment
https://forums.phpfreaks.com/topic/185365-select-where-in/
Share on other sites

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.