Jump to content

Archived

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

jaymc

How to test for strings usng an IN clause

Recommended Posts

Take a look at the below code

[code]SELECT * FROM artists WHERE ID IN (1,4,7,21,51) LIMIT 0,5[/code]

I'm sure you know what thats doing..

Well, ive just spend an hour trying to get this working..

[code]SELECT * FROM artists WHERE username IN (ste,jeff,peter) LIMIT 0,3[/code]

I can only assume the IN() stuff works with numbers only?

If not, what am i doin wrong, if so... how can I replicate the function but querying for usernames rather than ID's

Thanks

Share this post


Link to post
Share on other sites
You need to quote string literals.

Share this post


Link to post
Share on other sites
[code]
SELECT * FROM artists WHERE username IN ('ste','jeff','peter') LIMIT 0,3
[/code]

Share this post


Link to post
Share on other sites
Dam!! I didnt realise about the ' '

Thanks !

Share this post


Link to post
Share on other sites

×

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.