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. Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/ 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 Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300775 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. Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300924 Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds.... users.displayName REGEXP '[^0-9]%' Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300933 Share on other sites More sharing options...
The Little Guy Posted July 18, 2007 Author Share Posted July 18, 2007 nope Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300944 Share on other sites More sharing options...
clearstatcache Posted July 18, 2007 Share Posted July 18, 2007 try ds.... users.displayName REGEXP '^[0-9]' Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300947 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? Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300953 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? Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300959 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 Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300966 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.... Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300967 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 Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300969 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' Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300972 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))]' Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300976 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"; } ?> Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300981 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..? Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300984 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: !@#$%^&*(){}|[]\;':",./<>?`~+. Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-300986 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' Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-301019 Share on other sites More sharing options...
clearstatcache Posted July 19, 2007 Share Posted July 19, 2007 how was it little guy..... Link to comment https://forums.phpfreaks.com/topic/60466-mysql-start-of-word/#findComment-301941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.