Jump to content

server database


hisoka

Recommended Posts

Suppose I have a table in mysql server database and I want to add a row that fits these piece of

 

information

 

username = john

 

password = silverlight

 

is it true if I do it like this :

 

INSERT INTO table (username , password) values ('john' , 'silverlight');

 

 

??

 

this is the first question

 

 

 

the second question is :

 

 

 

are these two the same ???

 

 

 

INSERT INTO table (username , password) values ('john' , 'silverlight'); // without single quotes

 

 

INSERT INTO table ('username' , 'password') values ('john' , 'silverlight'); // with single quotes

 

if not what is the difference ?

Link to comment
Share on other sites

is it true if I do it like this :

Have you tested that to see if it works? You can answer your own question.

are these two the same ???INSERT INTO table (username , password) values ('john' , 'silverlight'); // without single quotesINSERT INTO table ('username' , 'password') values ('john' , 'silverlight'); // with single quotes

No, the second one will not work. You do not use single quotes around identifiers like table or column names. The only purpose of single quotes is to surround a string. A table or column name is not a string, it is an identifier.
  • Like 1
Link to comment
Share on other sites

is it true if I do it like this :

Have you tested that to see if it works? You can answer your own question.

 

Interesting :)

 

The thing is that as a newbie I do not know how to do it . Can you please tell me how to do it or test ? I do not have a website or a server

 

Should I install apache and php and mysql together in my computer ???

 

please tell me what to do and I will do it

 

best regards

Edited by hisoka
Link to comment
Share on other sites

I tried to download XAMPP from this site :

 

https://www.apachefriends.org/download.html

 

I have windows xp 32 bits and the application I tried to download is for windows xp 32 bits . However when I clicked run after saving it , it began to install and , suprisingly at the end , this error appeared :

 

C:xamppphpphp.exe is not a valid win32 application . I tried to download it again but the same error appeared .

 

So I changed the site and I went to another site :

 

http://sourceforge.net/projects/xampp/

 

and tried to download xampp : I tried two applications :

 

xampp-win32-5.6.3-0-vc..

 

xampp-win32-1.8.3-5.vc..

 

but when I try to install them , I got this error :

 

There has been an error : php versions 5.5 and later do not support windows xp

 

so I tried to find xampp with php versions 5.4 or earlier but I could not find one . Some I found but are with virus or adware (not false positive) : they caused problem in my computer .

 

So what could I do ?

 

thanks

Link to comment
Share on other sites

You can try to install everything manually, I guess. You could separately install and configure Apache, PHP, MySQL, and phpMyAdmin. The PHP site still has download links for version 5.4. You could also download that and try to install it over the version of PHP that comes with XAMPP. If you're using Windows XP your options are fairly limited.

Link to comment
Share on other sites

edited

 

now I solved many problems and php and mysql are configured to talk together . but I cannot configure mysql to talk with apache

 

Moreover , there is the connect command in cmd windows

 

when I use it like this

 

 

connect r : unknown mysql server host mysql? I am confused

Edited by hisoka
Link to comment
Share on other sites

but I cannot configure mysql to talk with apache

There's no link between MySQL and Apache. There's a link between MySQL and PHP, but not Apache.

connect r : unknown mysql server host mysql

That sounds like you're using "mysql" as a host name. You should use localhost.
Link to comment
Share on other sites

when I go to start - my programs - MySQL - MySQL server (version 5.1) - MySql command line client , the cmd of windows

 

appears in which it is stated : enter password .

 

After entering my password like that

 

enter password : *************

 

a paragraph appears : Welcome to Mysql monitor . commands end with ....................................type help or 'h' .....

 

mysql>

 

(ps : I read this http://dev.mysql.com/doc/refman/5.1/en/tutorial.html)

 

so now I am in cmd

 

then when I typed mysql , a pointer appeared then I typed again SELECT VERSION(), CURRENT_DATE; then another pointer appeared . No table appeared like in http://dev.mysql.com/doc/refman/5.1/en/entering-queries.html nothing only pointer like this :

 

mysql> mysql

->SELECT VERSION(), CURRENT_DATE;

->

 

 

So I said may be the database does not exist like in the error I got :

ERROR 1049 (42000): Unknown database 'r'

so I tried to create a database like this

 

mysql> CREATE DATABASE admin but the pointer appeared again and nothing else like this :

 

mysql> CREATE DATABASE admin

->

 

Whatsoever , I wrote come only a pointer -> and nothing more

 

mysql>

->

->

->

 

I do not understand why I got only a pointer with nothing else and that I cannot get any table or anything except a pointer -> with an empty value

 

I need help

 

thanks

Edited by hisoka
Link to comment
Share on other sites

THANK YOU FROM THE BOTTOM OF MY HEART.

 

now I understand why it shew only a pointer .

 

However I have something that confuses me a lot :

 

I created a table b with two columns named username and password . But when I saw the table using the DESCRIBE b;

 

the table was shown and I got six columns named field, type, null, key ,default ,extra . Normally and logically , after creating a table with two columns named username and password , I must get a table with two columns named username and password and not a table with six columns which have different names . So I am really confused why I got something different from the command I put !!? any explanation?

 

after the explanation , how do I get a table with the columns name I want and let mysql client command echoed it for me as I want it and should be and not as the mysql manual describes here

 

http://dev.mysql.com/doc/refman/5.0/en/creating-tables.html

 

http://dev.mysql.com/doc/refman/5.1/en/create-table.html

Link to comment
Share on other sites

So I am really confused why I got something different from the command I put !!? any explanation?

That's the output format of describe. The describe command does not change your table, it lists the columns in it.http://dev.mysql.com/doc/refman/5.5/en/explain.html

how do I get a table with the columns name I want and let mysql client command echoed it for me as I want it and should be

I don't know what you're asking, when you create a table you specify which columns it has, and those are the only columns the table has. MySQL does not add extra things that you didn't tell it to add.
Link to comment
Share on other sites

"I don't know what you're asking" I will reformulate my question so that I make myself clear :

 

I used this command : CREATE TABLE c1 (username char(20) , password char(20)); to create a table with two columns the first is named username and the second is called password and now we have a table with two columns named username and password

 

The problem is that I could not display the table c1 along with its two columns after creating it . By display I mean the table as a rectangle or a square divided in two columns the first called username and the second is password .

 

with these command I could not display the table I created along with its password and username columns

 

http://dev.mysql.com/doc/refman/5.5/en/show-create-table.html

 

http://dev.mysql.com/doc/refman/5.1/en/show-table-status.html

 

http://dev.mysql.com/doc/refman/5.6/en/show-tables.html

 

I am stuck :(

Link to comment
Share on other sites

I used the SELECT query statement to retrieve a row as you told me . Therefore , I got this table displayed+----+------+---+------| username  |password | +----+------+----------|   john    |  pass   |----------------------           

However , this is not what I want . After creating a table with twocolumns named username and password , I wanted to display only the table with its two coplumns named username and password like this:

+----+------+---+------| username  |password | +----+------+----------|           |         |---------------------- 

I could not display such a table even after using this command :

 

SELECT username , password FROM c1 ;

 

the result of this command is this :

 

Empty set (0.0 sec) (may be by "empty set" it means that there is no values inside the two columns and this is why the command did not display the table )

 

I still do not understand why I could not display it :(

Link to comment
Share on other sites

"I am not aware of any command to just show an empty result set listing the columns"

 

You mean it is impossible to get a table like this in mysql ?

+----+------+---+------| username  |password | +----+------+----------|           |         |---------------------- 

"or why you would even want to do that"

 

I believed that we can get such a table in mysql so I tried to get it displayed but I failed :) :)

+----+------+---+------| username  |password | +----+------+----------|           |         |----------------------  

Why we could not get such a table in mysql ??

Link to comment
Share on other sites

I don't see a reason for anyone to need a result set that contains no results. When you run a query it returns a result set. If there are no results it just says it's an empty result. You're trying to get a result set that apparently has 1 result but the values are empty. I don't see a reason for that. If you're trying to get the structure of the table then you use explain/describe and get a result set that contains 1 result for each column in the table and a lot more information other than just the column name. That's something that is useful, the empty result that you're trying to get isn't very useful.

  • Like 1
Link to comment
Share on other sites

Thank you

 

I have a question that confuses me : You told me this :

 

"Use a select query to retrieve rows from a table. It will format the result in the columns of the table"

 

once I used the select query as you told me , I got this table :

+----+------+---+------| username  |password | +----+------+----------|   john    |  pass   |---------------------- 

why I got the complete table with columns and rows instead of getting only the values of the row that I want to retrieve (here john and pass)!!? if I send a select query to the server database , normally it should return only the values in the rows not the entire table . Am I wrong? how?

Link to comment
Share on other sites

You're just seeing MySQL print out a little picture of what the result looks like. The actual result has a single row, not 2. The diagram that MySQL prints for you just has the column names in the first row. The actual result set only has 1 row.

Link to comment
Share on other sites

The select command is used to retrieve data from rows . In this table :

+----+------+---+------| username  |password | +----+------+----------|           |         |---------------------- 

there is one row (in which there are the names of the two columns) . Regardless of the table and the empty set ,why the values of this row (which are the names of the two columns namely username and password) cannot be retrieved like (john and pass)??

Link to comment
Share on other sites

That's not a row that gets returned. Like I said, MySQL is just drawing the table for you so that you can tell what the columns are. The names of the columns are not returned as a row in the result set.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...