Matching Text In A MySQL Database

free web hosting
Free Web Hosting > Computers & Tech > Databases

Matching Text In A MySQL Database

vizskywalker
I have a database that I am using to keep track of the members to my website. THe statements I used to create the database are as follows:
CODE
create database mousling_users

create table members(memberID int default \'0\' not null auto_increment, username char(20), password char(20), firstname char(20), lastname char(30), email char(50), privelege char(30), banned bool, primary key (memberID), unique id (memberID))

alter table members add fulltext (username)

The reason there are no prompt symbols or anything like that is I used a php page and mysql_query() to send these queries.

The problem comes in when trying to match records from the database with a string such as to check if a username already exists. Currently I have one record with a username of Vizsky, but when I send the query
CODE
select * from members where match (username) against ('Vizsky')
I get no records returned.

What am I doing wrong and how can I use queries to check when a username or password already exists?

~Viz

 

 

 


Reply

vhortex
CODE
select * from members where match (username) against ('Vizsky')


Hi vizskywalker,

your problem have so many work arounds.. dont be tie up with one single solution that is a big nono for programmers like us..

solution number 1 goes like this

CODE
select * from members where `username` = 'Vizsky'


what this piece of code do is to search the database for every records that have a username of Vizsky and return all column data that goes with it.

you already know the username so you can be sure that you can feed the query with the right username value..

now assuming that you only have a partial string for the username or you want all data that match the given username to be check..

example...

you have usernames of

user1
user2
user2
kim
foo
kee_user

and you want to find an excat match for user kee_user..

CODE
select * from members where `username` like  "kee_user"


this will return an exact match but we can extend that if you only have a portion of the username..

CODE
select * from members where `username` like  "user%"


returns all usernames that starts with the word user

CODE
select * from members where `username` like  "%user"


returns all usernames that ends with the word user

CODE
select * from members where `username` like  "%user%"


returns all usernames that haev the word user in the username

 

 

 


Reply

vizskywalker
Thank you, that worked. I am new to MySQL, and I was perusing the reference manual and the match thing appeared to be the solution. Just out of curiosity, however, do you have any idea why that didn't work? Also, if I use the `username` = 'Vizsky' thing, do I need to have username be a fulltext index?

~Viz

Reply

vhortex
QUOTE(vizskywalker @ Jun 2 2005, 10:55 AM)
Thank you, that worked.  I am new to MySQL, and I was perusing the reference manual and the match thing appeared to be the solution.  Just out of curiosity, however, do you have any idea why that didn't work?  Also, if I use the `username` = 'Vizsky' thing, do I need to have username be a fulltext index?

~Viz
*



no idea why it did not work..i dont use that anyway. well on my version of mySQL, the field do not need to be a full text.

in fact, i dont have any full text in my database. by the way my mySQL is version 3.x up.. never used a version lower than that.

current i am running 3.x, 4.x and 5 beta.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : matching, text, mysql, database

  1. Mysql Overhead
    (3)
  2. How To Understand A Database Schema
    A very nice and simple tutorial (4)
    Yesterday while i'm seaching for a data model and database schema at the Library of Free Data
    Models for a new project of a friend of mine i found there this nice and simple tutorial on How to
    Understand a Database Schema . As its name says, this tutorial will help you to better understand a
    Database Schema and covers the following basics topics that every Database Schema must define:
    QUOTE Primary and Foreign Keys. One-to-Many and Many-to-Many Relationships. Inheritance.
    "Rabbit's Ears", (Recursive relationships). The Scope of this tutorial is ....
  3. Best Database
    (7)
    What is the best free database if some one trying built a social networking website? And how to
    operate it with dreamweaver 8?....
  4. Some Useful Database Links.
    (7)
    I thought I would take a moment to point the users here to some of the database resources available
    for reference and learning. First I will start with actually designing the database. This site by
    R937 covers the basics of database design. The author is professional database guru and a frequent
    helper at the at DB forums listed below. The Library of Free Data Models is an excellent
    resource for finding data models for projects you may have or as examples of well put together data
    models. With around 500 data models the chances are you find something at least cl....
  5. Mysql Multiple Tables
    (1)
    It is good practice to use multiple tables to sort out big amounts of data. But once you do that it
    becomes increasingly hard to cross reference the tables. Mysql has a little beautiful command
    structure that they have added. You can select multiple tables within one sql query. Example of a
    basic sql query CODE $sql = "SELECT * FROM table WHERE row=1"; If you noticed
    that I selected all of the rows in the table. Normally you will try to not select the entire table
    from the database unless you absolutely want all of the table. I would recommend against....
  6. Any Website Provide Free Host Mysql Host?
    (4)
    any website provide free host mysql host? i need it because i am using 000webhost.com now but it
    only provide 2 mysql database... can i know where or how can i get more databases regards....
  7. Database Access On Remote Server W/jsp
    (0)
    Hello: I am new to JAVA and server-side applications and have a dumb question. I have set up
    Tomcat on my machine and created a JSP program to query an Access database using a DSN-Less
    connection. If I publish the page to a webserver and include the .MDB file will it work? I'm
    not sure exactly what needs to be packaged with my Java application to make it work. Since I
    don't have a remote server that supports .jsp I cannot really test it. I'm assuming that
    JDBC driver would be bundled with my site but not sure. Thanks!....
  8. Space Needed For Database
    (10)
    Iam assuming the information in the databases i will create will be stored in the 500 MB space i
    get, but since 500MB isn't enough iam wondering if you guys can tell me how much bytes the
    following take: Varchar(x),Tinyint,Text,date,smallint,mediumint,bigint,float.... And the rest
    present when you add/edit a row in a table. Also what are the ranges of tinyint,smallint,mediumint
    and big int....
  9. Mysql On Computer
    XD (9)
    I posted PHP on computer? , but for some reason it doesn't show :/. Anyways I am wondering if
    there is MYSQL on my computer, meaning can i make a data base on my computer? that way i make what i
    want and upload it when i get hosted =)....
  10. Mysql Database Entry By Excel Sheets
    (2)
    Hello .. I would like to ask if i can use use Microsoft excel files in order to make entries to
    mysql database. Thanks....
  11. Mysql Database Management
    (1)
    Hi i am new, I have a problem in understanding the query decomposition in D-DB. Can anyone help me
    to understand the first question of the exercise 25.21 of Elmasri-Navath 4th edition? Consider the
    following relations: BOOKS (Book#, Primary_author, Topic, Total_stock, $price) BOOKSTORE
    (Store#, City, State, Zip, Inventory_value) STOCK (Store#, Book#, Qty) Consider a distributed
    database for a bookstore chain called National Books with 3 sites called EAST, MIDDLE, and WEST.
    Consider that BOOKS are fragmented by $price amounts into: B1:BOOK1:up to $20.....
  12. Mysql And User File_priv
    (0)
    HI, I've hit the grain while trying to import file to mysql database - I need to enable file
    permissions of the database user but this seems not possible with most of the hosting providers.
    The problem is to set file_priv of the database user to "Y" . This is done in the "user" table of
    the maintanance database named "mysql". cPanel doesn't allow this. Via the cPanel you can only
    allow privileges on table querries but you cannot grant host file privileges to the database user -
    which makes querries like: "LOAD DATA INFILE 'filename' INTO TABLE tablen....
  13. Accessing Ms Access Database From A Centralized Location?
    (5)
    Hi I am a manager at a trading/wholesaling company (and have no programming background). I
    customized the Northwind sample access database to make invoices and keep accounts for my company.
    We now opening another office at a distant location. So, the order entry will be done at two
    points(we plan to use the same Access database). I am not able to figure out how to access the same
    MS Access database from two different location(as LAN can't be used). Moreover, we can't
    afford to pay huge sums to the software developers. Can intranet or uploading the database t....
  14. I Have An Error With My Mysql Connection
    mysql connection error (7)
    ok so here's my web page... http://lacrossems.t35.org/ it only lags cause its trying to
    connect to the my sql server...i followed this guide
    http://forum.ragezone.com/showthread.php?t=387249 and when i edit my config.php to my host and
    login info i always get the error cannot connect to the database here is my config.php if you can
    help me CODE <?php $host['naam'] =
    'CENSORED';                // my host $host['gebruikersnaam'] =
    'righto';       // my database username $host['wach....
  15. Mysql Backup With Another Address?
    (4)
    I just got my site hacked!! (don't worry because it is not on astahost) Actually it is a
    wordpress blog. So I backed up my MySQL Databases with cpanel. Now when I get my hosting approved
    here at astahost, can I restore those backups? Is the change of the site address going to interfere
    with this? Is there anyway I can edit those databases to work with my new address? Please help me
    out here!....
  16. Integrate Access Database Onto Intranet Site
    Looking to integrate access database into my intranet site (5)
    Hey guys, im new here and am looking for answers /tongue.gif" style="vertical-align:middle"
    emoid=":P" border="0" alt="tongue.gif" /> Firstly, i have designed a database using M$ access,
    it consists of multiple forms which i plan to host on an intranet website, i need to be able to add
    records directly from the form on the intranet website aswell as being able to edit/review current
    entries on forms in the database. My question is, how would i go about integrating these forms onto
    the intranet website? i plan on keeping the database and the intranet site on the s....
  17. Sun Bought Mysql
    (6)
    SUN bought the swedish company MYSQL for much money, around 2million each worker got in the company,
    they did it to come in to the database market, is it a good reson to buy it?....
  18. Database
    prblem with it (1)
    i have free script but it is working fine on a lot of sites i tried to use it to my web site ....i
    edit its config.php right and but my database name and my user name and password every thing right
    and when i try to install it it gives me this error can`t connect to database please choose
    file from this mobile.sql can any body help plz coz i tried huderd of times and no thing happend....
  19. Connecting To A Remote Database
    (9)
    I wondered if anyone here can help. I have a database on a remote server (A). I want to access it
    through a php script on a different server C. I have allowed access on (A) in Cpanel - mysql dbases
    - Remote Access by putting the IP address of server C The host of server (A) has also whitelisted
    the IP of server C. Though I am having trouble connecting from server C which is with a different
    webhost. any ideas how to get round this? I have though of SSH forwarding, but I think this can
    only be used to connect a client - e.g. my pc to the remote server A. I do not ha....
  20. Mysql - So Hard
    Come in here if you think MySQL is soo hard! (14)
    Doesn't anybody think MySQL is so hard to code? I mean think about it, you need loads of
    databases just for one little script and you have to type things in like ;Host-Username:
    (blahblah) ;Host-Password: (blahblah) ;Host-DatabaseName: (blahblah) Ok, that MySQL code was
    random, and it is alot harder than that. If you have expierenced it being hard, you are free to
    post right in here, mate.....
  21. Login System Using A Mysql Db
    How do i do this? (5)
    Hi guys, ive got a registration system that looks something like the one below: Firstname:
    Lastname: Then i have inset.php, which looks like the following: $con =
    mysql_connect("localhost","autobot","abc123"); if (!$con) { die('Could not connect:
    ' . mysql_error()); }mysql_select_db("my_db", $con);$sql="INSERT INTO person
    (username, password) VALUES ('$_POST ','$_POST ')";if
    (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record
    added";mysql_close....
  22. Mysql And Php
    When trying to install Joomla (15)
    I don't know if this is the correct forum, but here is my question: I'm trying to test
    Joomla and some forums in my computer, I have already installed MySQL with the GUI tools, Apache,
    and PHP with the MySQL and MySQLi extensions, but when I'm trying to install Joomla I get this
    error: Required Settings Check: ------------------------------------- PHP version >= 4.1.0
    Yes - zlib compression support Available - XML support Available - MySQL support
    Unavailable configuration.php Writeable Session save path Unwriteable Not ....
  23. Navcat For MySQL
    is Navcat any good? (9)
    Hello all, i ve recently come across NavCat (GUI tool) for MySQL. I have not bought a copy yet, just
    played around with the demo. Has any one used it beore, if so please let me know if its worth
    buying. I already have PhpMyadmin, Just wanna know if NavCat is better than PhpMyAdmin in usibility
    and functionality. Regards....
  24. MySQL, Multiple Tables
    (24)
    Ok, I'm coding a project which is a leap than what I'd normally do. Before, I've always
    learned ONE table... put EVERYTHING in one database table. I'm making a profile system so there
    needs to be at least two tables: 1 for users, 1 for content. My problem is, how do I link the two
    together? I could probably figure this out faster if someone explained and posted sample SQL code
    that shows how the two are linked together. Thanks!! F....
  25. MySQL Output Database Question
    (18)
    I am new to MySql and have just created a database after using a script. My problem is not the
    script, but what it says about putting it into the output file. I cant figure out the right terms
    to put it in, I keep getting errors. I try using; SELECT*FROM 'database name' WHERE
    'location' but it isnt working. I'm lost with this stuff, I really am. Can someone
    please help me out?....
  26. How To Connect MySQL With Flash?
    Help me connect my flash Work with MySql (8)
    I know Flash and mysql but could not figure out if I could ever connect these? I want to have a
    dynamic content in my flash object that could be retrieved from the database directly without myself
    needing to update it again and again. How can I achieve this ? Do I have to install any additional
    controls or connectors to do that ? If yes any one tell me....
  27. Mirror My MySQL Database To Another Mysql Server
    (4)
    Hi..I want to ask if its possible to automatically mirror my mysql databases into another mysql
    server?or create a small php script to do this? The reason is because, we all know that database is
    very improtant if we have dynamic website. I have my forum hosted and i want to automatically
    mirror this or backup into another mysql server(free). Like in freesql.org. So that im not afraid
    that i forgot to backup my database..also i have one central backup database. Thanks for the
    help..Im looking forward for this posibility.....
  28. Recover Tables From A MySQL .frm File
    (8)
    I have a couple of .frm files with no corresponding data or index files. Is it possible to recover
    the table structure (field names, types, sizes, rows,col, etc) from these files? The table type is
    innodb....
  29. MySQL Realtime Replication
    how to replicate mysql in realtime (4)
    i dont know if this might be useful to ppl here, but this is a very good knowledge for serious
    siteadmins. while i was digging for mysql backup techniques, i've found that mysql is able to
    do realtime replication. the idea is that there are master server and slave server. both are having
    the same version of mysql installed. the data flows; Master >copy> Slave ( in realtime!)
    you'll never have to manually copy the database file of wasting your time to manually use the
    mysqldump command. here are the links; http://dev.mysql.com/doc/mysql/en/Replication_HOW....
  30. MySQL - Trouble With Bulk Insert Statements
    (3)
    I'm trying to insert about 500 rows into mysql, but I keep getting errors. If I copy and paste
    too many (about 50) insert statements at a time I get errors sometimes. I sometimes even get errors
    but then the row is skipped so I don't know there was an error (I'm using linux and SSH).
    What's the best way to get my insert statements to put the data in MySQL? Is there anyway that I
    can have it tell me if there where any errors all the statements are executed? Thanks for your
    help.....

    1. Looking for matching, text, mysql, database

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for matching, text, mysql, database
advertisement




Matching Text In A MySQL Database



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE