Home > database >  New people for help, self-study small problems
New people for help, self-study small problems

Time:09-26

New people new to SQL statements, self-study in , there are two small question to answer,

In accordance with the format below and insert row 2 specifies the column name can but according to the format 1 tip failure is why

Format: 1 INSERT INTO table name VALUES (the value 1, 2,... )


Format 2: INSERT INTO table_name (column 1, 2,... ) VALUES (the value 1, 2,... )


2. The nested function
MySQL is like Max (avg (chengji)) this nested function can't use, can only use a subquery to replace

I would appreciate your looking great god answer

CodePudding user response:

Columns do not match, which means your table may have five columns but you just insert the four columns

CodePudding user response:

There are other columns, you select *,
Can be nested functions

CodePudding user response:

Although the first insert no problem, but require you to value field and complete corresponding data table fields; If the later data tables have change, may be wrong;

Suggested inserted in the second way, after the name of the table will write clear field.

CodePudding user response:

reference baidu_36457652 reply: 3/f
, and other columns, you select *,
Can be nested function

Ask, nested function words how nested, in this way I do

CodePudding user response:

reference 5 floor Vsir_Tun reply:
Quote: refer to the third floor baidu_36457652 response:

There are other columns, you select *,
Can be nested function

Ask, nested function words how nested, I in this way can't

Write your post

CodePudding user response:

Advanced query SELECT

http://www.verejava.com/? Id=1717413210274

CodePudding user response:

reference baidu_36457652 reply: 3/f
, and other columns, you select *,
Can be nested function

Example: the balance of accounts for the same day the average of the maximum value, and show the time and the maximum opening an account,
The SELECT KHSJ, Max (avg (make) FROM ZHXXB group by KHSJ
Temporarily no specific instances, this is just one example of the document, I taught myself, but no nested function

CodePudding user response:

refer to the eighth floor Vsir_Tun response:
Quote: refer to the third floor baidu_36457652 response:

There are other columns, you select *,
Can be nested function

Example: the balance of accounts for the same day the average of the maximum value, and show the time and the maximum opening an account,
The SELECT KHSJ, Max (avg (make) FROM ZHXXB group by KHSJ
Temporarily no specific instances, this is just one example of the document, I taught myself, but nested functions are not

You keep this place Max (avg (make)) this is what ah,,

CodePudding user response:

The first question:
You the number of columns of it should not be seven columns, so insert error, insert the number of columns to concur with the number of columns in the table, I'm not sure on the primary key, you can try,
And suggest you use the second method from start practice, can forget the first, after that cooperative development with everyone else, even if someone changes of table structure, as long as there is your writing table field in should there would be no problem, or someone else may affect both add columns subtract column
The second question:
I met a temporary situation cannot use two functions, the invalid use of group function

CodePudding user response:

Take a look at your watch how many columns, more or less thrust,
Mysql can be nested functions

CodePudding user response:

The SELECT KHSJ, avg (make) FROM ZHXXB group by KHSJ order by avg (make) desc limit 1
Give it a try

CodePudding user response:

Basic command MySql DDL DML

http://www.verejava.com/? Id=1717411998521

CodePudding user response:

Mysql see more books,
Deep understanding of MySQL
  • Related