Jump to content

Why does not this query work?


Rommeo

Recommended Posts

I m trying to get the photos that are not in the list..

and my query is this that is not working ;

 

SELECT *

FROM photos

WHERE photoname NOT IN (

"one.jpg, two.jpg"

)

ORDER BY visited ASC

LIMIT 0 , 10

 

query gives me the 10 photos including one.jpg and two.jpg

 

but weirdly when there is just one photo between the "IN" tags, it works, like;

 

SELECT *

FROM photos

WHERE photoname NOT IN (

"one.jpg"

)

ORDER BY visited ASC

LIMIT 0 , 10

 

What am I missing here?

any other keyword do I need to use here?

 

PS : list is comma seperated like one.jpg,two.jpg,three.jpg

Link to comment
Share on other sites

each value that you are comparing against the specified field should be separated by a comma.

 

SELECT *
FROM photos
WHERE photoname NOT IN (
"one.jpg, two.jpg"
)
ORDER BY visited ASC
LIMIT 0 , 10

 

this will check to make sure that the field value is not equal to the literal string "one.jpg,two.jpg".

this is the correct query.

 

SELECT *
FROM photos
WHERE photoname NOT IN (
"one.jpg", "two.jpg"
)
ORDER BY visited ASC
LIMIT 0 , 10

Link to comment
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.