Forum Moderators: coopster

Message Too Old, No Replies

MySQL Questions (Help appreciated!)

         

aznbruinboy

9:48 am on Jul 7, 2004 (gmt 0)

10+ Year Member



Hi, I'm new to using mysql and these questions will probably seem very trivial, but i've been having a lot of trouble and none of the tutorials i've found explain these:

1) how do i check the elements or entries i've inserted into a table in mysql? I've created a table format notepad and creating a test.sql file and loading it in notepad. This works out fine, but then i try to insert into the table. (my table name is accounts)

INSERT INTO accounts (Username,
Password,
IPaddress)
VALUES ('Account 2',
'Pword for 2',
'100.1.1.2');

but how do i check if this element has been successfully inserted into the table? also, i had to enter this all from the mysql prompt. Is there nay way i can just use notepad to do all this? Also, how come the entries don't stay in the table when i reload it after closing hte mysql/dos program?

Thanks so much for the help! Sorry about the noobish questions.

coopster

3:30 pm on Jul 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, aznbruinboy!

To verify your entry in the table, you now use the SELECT statement.

SELECT * FROM accounts; 
or maybe you just want to see certain columns:
SELECT Username, Password FROM accounts;
now sort them:
SELECT Username, Password FROM accounts ORDER BY Username;
or maybe just one user:
SELECT Password, IPaddress FROM accounts WHERE Username = 'me';

Yes, you can key all your commands into a text file and then process the text file from the command line:

mysql -u username -p databasename < mytextfile.txt
Using this syntax will prompt you for a password.

A great resource for you will be the MySQL manual. Particularly the Tutorial [dev.mysql.com] to get you started.

ergophobe

3:44 pm on Jul 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



edit: ahh... the dangers of opening several tabs when reading WebmasterWorld. Sorry for the double post]

First of all, it should return a comment like

"x rows affected" or something like that.

If you want to see it, type in

SELECT * FROM accounts

or

SELECT * FROM accounts WHERE username='Account 2'

Tom

randallxski

4:18 pm on Jul 7, 2004 (gmt 0)

10+ Year Member



There are GUI tools available for Unix and Windows to help with the database setup and testing. On Windows, MySQL Control Center works or the pre-packaged WinMySQLAdmin is marginally okay. On one of my Unix/Apache hosts, I think I have phpMyAdmin available, which is a pretty good interface.

brucec

4:35 pm on Jul 7, 2004 (gmt 0)

10+ Year Member



I like PhpMyAdmin.

brucec

4:36 pm on Jul 7, 2004 (gmt 0)

10+ Year Member



One way to solve it is to sow the Insert statement again as you post the data to the tables.