If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-12-08, 13:50
banjax banjax is offline
Registered User
 
Join Date: Nov 2008
Posts: 1
Search

I need to know if anyone knows how to search a database and sort out entries by name age etc

for example:
these three entries are entered into the table
Alex-14
Jim-15
zach-19
Aaron-15
now say i wanted to search and be able to find all users that begin with the letter A. i would click the letter A then only Alex and Aaron would come up

do you guys understand or do you need more info.

Also i need to know a very simple way of making a private message system
Reply With Quote
  #2 (permalink)  
Old 11-12-08, 14:09
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
is this a SQL problem or an application problem

at first glance the SQL is pretty trivial

select my,column,list from mytable where mynamecolumn like "A$"

an alternative would be
select my,column,list from mytable where left(mynamecolumn,1,1) = "A"

however youmention you want to click on a letter, so that means your problem also relates to how you access your data (the front end, the user interface), and yyou give no clues as to what front end you are usign
it could be a web page a more traditional user interface (such as VB, VC, C#,.NET, Java)

if its a web page then you may want to look at AJAX on a PHP script
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 11-12-08, 14:39
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
healdem, mysql uses the standard percent sign as its wildcard character for LIKE, not the dollar sign



Quote:
Originally Posted by banjax
Also i need to know a very simple way of making a private message system
you'll need three tables -- users, messages, recipients

the users table contains one row for each user

the messages table contains one row for each message, with a foreign key to the user who sent it

the recipients table contains one row for each recipient of each message, with foreign keys to the message and to the user who is the recipient

that should get you started

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 11-12-08, 16:09
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
oops my bad....

sorry the $ was a typo, as ignorant as I am in SQL,even I knew % is the MySQL wildcard
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On