Lists in the Where clause

5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 21, 2009   (RSS)

Re: [InHouse] Lists in the Where clause

By InHouse - August 20, 2009

FWIW here's what eventually worked:

'where' => "`group` = 'right' ",


Note the PHPMyAdmin style quotes `.

The interesting part was that the escaped tab characters (/t) were not being honoured.

Solved otherwise.

Re: [InHouse] Lists in the Where clause

By Chris - August 21, 2009

Hi InHouse,

Sorry to hear you ran into trouble and I'm glad you've got it figured out.

One thing that may have been causing problems is that GROUP is a reserved word in MySQL. Putting it in quotes would definitely avoid that problem.

As for your tab characters, you'll need to use a backslash instead of a forward slash, e.g.:

'where' => ' `group` LIKE "%\tleft\t%" ',

Hope this helps!
All the best,
Chris

Re: [chris] Lists in the Where clause

By InHouse - August 21, 2009

Thanks Chris.

You're quite right about the escape character of course. As I get older late nights become hazy for different reasons than in my youth. ;-) <sigh>

While I have your attention though, do you know any syntax for doing and OR in the WHERE statement. My normal attempts have not worked out.

J.

Re: [InHouse] Lists in the Where clause

By Chris - August 21, 2009

Hi InHouse,

The only gotcha I can think of is that you have to specify the field name again, e.g.:

'where' => ' `group` LIKE "%\tleft\t%" OR `group` LIKE "%\tright\t%" ',

Hope this helps! If not, please post the details of what you're trying to accomplish.
All the best,
Chris