The Little Guy Posted July 18, 2007 Share Posted July 18, 2007 anyone know how to search for something starting with a number in mysql? and is there a way to find something starting with a symbol? I have this, which doesn't work: users.displayName LIKE '0-9%' but these work individually: users.displayName LIKE '0%' users.displayName LIKE '1%' users.displayName LIKE '2%' and so on, but that doesn't work for me, I need to have it so it will find everything starting with a number on the first search, same thing with symbols. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 18, 2007 Share Posted July 18, 2007 dude use the [^a-z0-9] heard about that wild char of sql that will do Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 users.displayName LIKE '[^0-9]%' or users.displayName LIKE '[^0-9]' neither of these work. Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds.... users.displayName REGEXP '[^0-9]%' Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 nope Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds.... users.displayName REGEXP '^[0-9]' Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 There we go... that worked, now How would I do symbols? for users.displayName? Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 do you want to get the names starting with a specific symbol or whatever symbols? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 names starting with any symbol Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds..... users.displayName REGEXP '^.' ds will get all the names whatever it start.... Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 nope, that grabs everyone. OK... I have links, that you can browse users, you can search by the following: - Letter - 0-9 - Symbol - All friends Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 hehehe....i misunderstood it..... try ds 1.. users.displayName REGEXP '^\W' Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds also... users.displayName REGEXP '^[^((a-z)|(0-9))]' Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 OK... Here is what I have: <?php $letter = addslashes($_GET['lett']); if($letter != '0-9' || $letter != 'symbol'){ $query = "SELECT * FROM friends_friends,users WHERE friends_friends.friend = '1' AND (friends_friends.myFriend = '$id' OR friends_friends.theirFriend = '$id') AND IFNULL(users.displayName LIKE '$letter%', users.fname LIKE '$letter%') AND ((friends_friends.theirFriend = users.id AND friends_friends.theirFriend != '$id') OR (friends_friends.myFriend = users.id AND friends_friends.myFriend !='$id')) ORDER BY addDate"; }elseif($letter == 'symbol'){ $query = "SELECT * FROM friends_friends,users WHERE IFNULL(users.displayName REGEXP '^[^((a-z)|(0-9))]', users.fname REGEXP '^[^((a-z)|(0-9))]') AND friends_friends.friend = '1' AND (friends_friends.myFriend = '$id' OR friends_friends.theirFriend = '$id') AND ((friends_friends.theirFriend = users.id AND friends_friends.theirFriend != '$id') OR (friends_friends.myFriend = users.id AND friends_friends.myFriend !='$id')) ORDER BY addDate"; }else{ $query = "SELECT * FROM friends_friends,users WHERE friends_friends.friend = '1' AND (friends_friends.myFriend = '$id' OR friends_friends.theirFriend = '$id') AND IFNULL(users.displayName REGEXP '^[0-9]', users.fname REGEXP '^[0-9]') AND ((friends_friends.theirFriend = users.id AND friends_friends.theirFriend != '$id') OR (friends_friends.myFriend = users.id AND friends_friends.myFriend !='$id')) ORDER BY addDate"; } ?> Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 whats the result of the code? did u get wat u want..? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 yes, except when I am doing a symbol search. I can search by letter, and by numbers, but not symbols, unless I type the symbol in the address bar. these all work: http://publicsize.com/friends/viewFriends?action=letter&lett=# http://publicsize.com/friends/viewFriends?action=letter&lett=$ http://publicsize.com/friends/viewFriends?action=letter&lett=1 http://publicsize.com/friends/viewFriends?action=letter&lett=8 http://publicsize.com/friends/viewFriends?action=letter&lett=g http://publicsize.com/friends/viewFriends?action=letter&lett=k But this doesn't: http://publicsize.com/friends/viewFriends?action=letter&lett=symbol I want the above ^^^ URL to search for all types of symbols like these: !@#$%^&*(){}|[]\;':",./<>?`~+. Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 have u tried ds...? users.displayName REGEXP '^\W' if still won't work...bwt ds 1.... users.displayName REGEXP '^\pS' Quote Link to comment Share on other sites More sharing options...
clearstatcache Posted July 19, 2007 Share Posted July 19, 2007 how was it little guy..... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.