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