Question

I have two very simple questions:

  1. what is name of a select statement result table in MySQL (a name that I can use in another select statement, for example in next line)?
  2. how to naming that above table (in question 1)?
Était-ce utile?

La solution 3

it was found. I must use views.

Autres conseils

1- what is name of a select statement result table of in mysql?(a name that I can use it in another select statement(for example in next line))

Resultsets will not have any name unless you define an alias name while executing.

select * from department dept

In the above example dept is an alias name for department table.

2- how to naming that above table(in question 1)?

There could be cases where you select information from a single or multiple tables and join together. For that whole set you can define an alias.

select 
  emp_id, salary, commission, 
  ( salary + commission ) as total_sal,
  dept.dept_name as department_name
from employee emp, department dept
  where emp.dept_no = dept.dept_no

For the above query you can give alias when used like:

select * from (
  select 
    emp_id, salary, commission, 
    ( salary + commission ) as total_sal,
    dept.dept_name as department_name
  from employee emp, department dept
    where emp.dept_no = dept.dept_no
) as filtered_results
where
  department_name in ( 'sales', 'marketing' )

Refer to:
MySQL: Schema Object Names

If I am correct, you wish to create a from a select command in mysql? This should work.

CREATE TABLE fishTypes (type VARCHAR(100)) SELECT type FROM allFish;

Is this the solution you are looking for? Here allFish might have the schema (number INT, type VARCHAR(100))

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top