Jump to content

mysql start of word


The Little Guy

Recommended Posts

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

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

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

Archived

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

×
×
  • 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.