SELECT PvtMsgTitle,Sender,TimeSent,Status,SendTo,ID FROM pvtmsg WHERE SendTo LIKE '$User[0]' OR '%,$User[0]'
The problem with the query above is that only the first pattern in LIKE is working. I know for a fact that theres something that matches the seconde pattern, so why isn't it working? If I change the order of the patterns only the first one ('%,$User[0]') works.
matches the seconde pattern
What second pattern? There is only one like predicate in your statement.
The one after the OR.
Check out MySQL (I'm assuming MySQL as you haven't given the db being used) LIMIT syntax here
The problem is you that you can't do what you're trying to with LIKE. Have a read of the link above and try to figure out what's wrong. If you can't post back and I'll give you a hand.
HTH Bubble
I already looked there (I always look before I ask) and failed to see a problem with the syntex. Yes i'm using mySQL.
Where does it say on that page that you can write field LIKE 'value1' OR 'value2'? It doesn't, that generally means that you can't. Now, just take a step back for minute and look at it calmly. What would be another logical way of expressing what you're trying to there?
HINT:: It's a longer way of expressing it.
BIG HINT:: In PHP what would the result of this be? if($a == 'this' || 'that') How would you re-write it?
Hehe, thanks :p
No problem 🙂
I don't know why I didn't think about this before but I need to get anything that contains one of those patterns in one query which I can't do this way =/ Any ideas?
No,no,no, I thought you'd got it. The clues where there. You have to expand it.
SELECT PvtMsgTitle,Sender,TimeSent,Status,SendTo,ID FROM pvtmsg WHERE SendTo LIKE '$User[0]' OR SendTo LIKE '%,$User[0]'
Come on, you should have got that :bemused:
Thanks agin... Thats like the only combo I didn't try X_x