Jump to content

SELECT WHERE IN()


lbillett

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.