这个sql语句怎么写?有三个表如下users(id,name);type(id,name);note(id,title,contents,user_id,author_id,type_id);其中,user_id是作者、author_id是原创作者都是与users中的id进行关联的,type_id是分类编号,与type的id关联。现在需要创建一个视图显示note中的id、title、contents、user_id、author_id、type_id、以及user_id、author_id、type_id

题目
这个sql语句怎么写?

有三个表如下

users(id,name);

type(id,name);

note(id,title,contents,user_id,author_id,type_id);

其中,user_id是作者、author_id是原创作者都是与users中的id进行关联的,type_id是分类编号,与type的id关联。

现在需要创建一个视图显示note中的id、title、contents、user_id、author_id、type_id、以及user_id、author_id、type_id对应的name。

怎样写sql语句呢?


相似考题
更多“这个sql语句怎么写? 有三个表如下users(id,name);type(id,name);note(id,title,contents,user_id,author_id,type_id);其中,user_id是作者、author_id是原创作者都是与users中的id进行关联的,type_id是分类编号,与type的id关联。现在需要创建一个视图显示note中的id、titl”相关问题
  • 第1题:

    YoucreateaWebpagethatcontainsthefollowingcode.Youneedtoprovidethefollowingimplementation.EachtimetheAddFilebuttonisclicked,anewdivelementiscreated.ThenewdivelementisappendedaftertheotherfileuploaddivelementsandbeforetheAddFilespan.Eachnewelementhasauniqueidentifier.Whichcodesegmentshouldyouuse?()

    A.$("#AddFile").click(function(){varid="File"+++lastId;varitem=$(".File:first").clone(true);$("input:file",item).attr({id:id,name:id});item.insertBefore("#AddFile");});

    B.$("#AddFile").click(function(){varid="File"+++lastId;$(".File:first").clone(true).attr({id:id,name:id}).insertBefore("#AddFile");});

    C.$("#AddFile").click(function(){varid="File"+++lastId;});

    D.$("#AddFile").click(function(){varid="File"+++lastId;varitem=$(".File:first").clone(true);$("input:file",item).attr({id:id,name:id});item.insertAfter("input[type=file]");});


    参考答案:A

  • 第2题:

    mysql登录命令加sql语句怎么写

    登录命令后面直接加要执行的sql语句怎么写?

    mysql -u root -proot insert into tab (id,name) value ('1','abc') 

    这样写对不对?


    你要执行sql语句必须要用 -e这个选项后面加要执行的语句 -D后加的是你要操作的数据库的名字,如下命令mysql -D 指定的数据库名 -u root -p root -e 'insert into table (id,name) value ('1','abc')'请把上句中的table换成你要操作的表名,这样子就OK了

    希望可以帮到您,别忘了采纳哟,愿您生活愉快!!

  • 第3题:

    某企业的数据库系统中有如下所示的员工关系和仓库关系,每个仓库可有多名员工,但只有一名负责人。

    员工关系(employee):

    仓库关系(warehouse):

    则创建仓库表结构的SQL语句为(58)。

    A.CREATE TABLE (employee ID CHAR(2)NOTNULL UNIQUE, name CHAR(30)NOT NULL, address CHAR(40), principal ID CHAR(3));

    B.CREATE warehouse(warehouse ID CHAR(2)PRIMARY KEY, name CHAR(30), address CHAR(40), principal ID CHAR(3));

    C.CREATE TABLE warehouse(warehouse ID CHAR(2)PRIMARY KEY, name CHAR(30)NOT NULL, address CHAR(40), principal ID CHAR(3), FOREIGN KEY(principal ID)REFERENCES employee(employee ID));

    D.CREATE TABIE warehouse(warehouse ID CHAR(2), name CHAR(30)NOT NULL, address CHAR(40), principal ID CHAR(3), PRIMARY REY(warehouse ID), FOREIGN KEY(employee ID)REFERENCES employee(employee ID));


    正确答案:C

  • 第4题:

    INSERT INTO TEST VALUES(‘&ID’,‘&NAME’); 语句在执行时将()

    • A、编译错:提示变量未定义
    • B、运行错:提示不能识别符号
    • C、将值&ID和&NAME插入到表中
    • D、提示用户输入ID和NAME的值,再将输入值插入表中

    正确答案:D

  • 第5题:

    下列哪种方式可以在session中保存一个名为"name",值为"newer"的属性()

    • A、request.getSession().setAttribute(“name”,"newer")
    • B、request.getSession().getAttribute(“ID”,id);
    • C、request.getSession().setParameter(“ID”,id);
    • D、request.getSession().getParameter(“ID”,id)

    正确答案:A

  • 第6题:

    The EMPLOYEES table contains these columns: EMPLOYEE_ID NUMBER(4) LAST_NAME VARCHAR2 (25) JOB_ID VARCHAR2(10) You want to search for strings that contain 'SA_' in the JOB_ID column. Which SQL statement do you use?()

    • A、SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA/_%' ESCAPE '/';
    • B、SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_';
    • C、SELECT employee_id, last_name, job_id FROM employees WHERE job_id LIKE '%SA_' ESCAPE "/";
    • D、SELECT employee_id, last_name, job_id FROM employees WHERE job_id = '%SA_';

    正确答案:A

  • 第7题:

    You created a view called EMP_DEPT_VU that contains three columns from the EMPLOYEES and DEPARTMENTS tables: EMPLOYEE_ID, EMPLOYEE_NAME AND DEPARTMENT_NAME. The DEPARTMENT_ID column of the EMPLOYEES table is the foreign key to the primary key DEPARTMENT_ID column of the DEPARTMENTS table. You want to modify the view by adding a fourth column, MANAGER_ID of NUMBER data type from the EMPLOYEES tables. How can you accomplish this task?()

    • A、ALTER VIEW EMP_dept_vu (ADD manger_id NUMBER);
    • B、MODIFY VIEW EMP_dept_vu (ADD manger_id NUMBER);
    • C、ALTER VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employee e, departments d WHERE e.department _ id = d.department_id;
    • D、MODIFY VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department _ id = d.department_id;
    • E、CREATE OR REPLACE VIEW emp_dept_vu AS SELECT employee_id, employee_name, department_name, manager_id FROM employees e, departments d WHERE e.department _ id = d.department_id;
    • F、You must remove the existing view first, and then run the CREATE VIEW command with a new column list to modify a view.

    正确答案:E

  • 第8题:

    Examine the structure of the EMPLOYEES and DEPARTMENTS tables: EMPLOYEESColumn name Data type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2 (30) JOB_ID VARCHAR2 (20) SALARY NUMBER MGR_ID NUMBER References EMPLOYEE_ID COLUMN DEPARTMENT ID NUMBER Foreign key to DEPARTMENT ID column of the DEPARTMENTS table DEPARTMENTSColumn name Data type Remarks DEPARTMENT_ID NUMBER NOT NULL, Primary Key DEPARTMENT_NAME VARCHAR2(30) MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table Evaluate this SQL statement: SELECT employee_id, e.department_id, department_name, salary FROM employees e, departments d WHERE e. department_id = d.department_id; Which SQL statement is equivalent to the above SQL statement?()

    • A、SELECT employee_id, department_id, department_name, salary FROM employees WHERE department_id IN (SELECT department_id FROM departments);
    • B、SELECT employee_id, department_id, department_name, salary FROM employees NATURAL JOIN departments;
    • C、SELECT employee_id, d.department_id, department_name, salary FROM employees e JOIN departments d ON e.department _ id = d. department_id;
    • D、SELECT employee_id, department_id, department_name, Salary FROM employees JOIN departments USING (e.department_id, d.department_id);

    正确答案:C

  • 第9题:

    Examine the structure if the EMPLOYEES table: Column name Data Type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) NOT NULL SAL NUMBER MGR_ID NUMBER References EMPLOYEE_ID column DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the DEPARTMENTS table You need to create a view called EMP_VU that allows the user to insert rows through the view. Which SQL statement, when used to create the EMP_VU view, allows the user to insert rows?()

    • A、CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, department_id FROM employees WHERE mgr_id IN (102, 120);
    • B、CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, job_id department_id FROM employees WHERE mgr_id IN (102, 120);
    • C、CREATE VIEW emp_Vu AS SELECT department_id, SUM(sal) TOTALSAL FROM employees WHERE mgr_id IN (102, 120) GROUP BY department_ id;
    • D、CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, job_id, DISTINCT department_id FROM employees;

    正确答案:B

  • 第10题:

    单选题
    Examine the structure of the EMPLOYEES table: Column name Data type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) NOT NULL SAL NUMBER MGR_ID NUMBER References EMPLOYEE_ID column DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the DEPARTMENTS table You need to create a view called EMP_VU that allows the users to insert rows through the view. Which SQL statement, when used to create the EMP_VU view, allows the users to insert rows?()
    A

    CREATE VIEW emp_vu AS SELECT employee_id, emp_name, department_id FROM employees WHERE mgr_id IN (102, 120);

    B

    CREATE VIEW emp_vu AS SELECT employee_id, emp_name, job_id, department_id FROM employees WHERE mgr_id IN (102, 120);

    C

    CREATE VIEW emp_vu AS SELECT department_id, SUM(sal) TOTALSAL FROM employees WHERE mgr_id IN (102, 120) GROUP BY department_id;

    D

    CREATE VIEW emp_vu AS SELECT employee_id, emp_name, job_id, DISTINCT department_id FROM employees;


    正确答案: B
    解析: 暂无解析

  • 第11题:

    单选题
    现有表book,字段:id(int),title(varchar),price(float);其中id字段设为自增长的标识,使用insert语句向book表中插入数据,以下语句错误的是()。
    A

    insertintobook(id,title,price)values(1,’java’,100)

    B

    insertintobook(title,price)values(’java’,100)

    C

    insertintobookvalues(’java’,100)

    D

    insertbookvalues(’java’,100)


    正确答案: D
    解析: 暂无解析

  • 第12题:

    ( 难度:中等)在Hive中,以下哪个SQL语句是错误的
    A.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
    > FROM CUSTOMERS c
    > LEFT OUTER JOIN ORDERS o
    > ON (ID = o.CUSTOMER_ID);
    B.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
    > FROM CUSTOMERS c
    > RIGHT OUTER JOIN ORDERS o
    > ON (ID = o.CUSTOMER_ID);
    C.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
    > FROM CUSTOMERS c
    > FULL OUTER JOIN ORDERS o
    > ON (ID = o.CUSTOMER_ID);
    D.hive> SELECT ID, NAME, o.AMOUNT, o.DATE
    > FROM CUSTOMERS c
    > FULL OUTER JOIN ORDERS o
    > ON (ID = o.CUSTOMER_ID OR Name = o.Name);

    答案:D

  • 第13题:

    假设一连锁书店的数据库中有3个表:连锁分店信息表STORES(STOR ID,STOR NAME),书籍销售信息表SALES(STOR ID,TITLE ID,QTY)和书籍信息表TITLES (TITLE ID,TITLE)。要查询各分店销售某书的数量,相应的SQL语句应该是:

    SELECT STOR_NAME,QTY,TITLE

    FROM TITLES,STORES,SALES

    WHERE TITLES.TITLE_ID=SALES.TITLE_ID AND【 】。


    正确答案:STORES.STOR ID=SALES.STOR ID
    STORES.STOR ID=SALES.STOR ID 解析:连锁分店信息表STORES里只存储了分店号和店名,书籍销售表SALES存储了分店号,书籍编号和该编号书在该编号分店的销售量,书籍信息表TITLES则存储了书籍编号和书名,所以要查询各分店某书对应的销售量,就要依据这3个表的相同属性进行等值连接,其中表 SALES因为与其他两个表都有联系,充当了“桥梁”的作用,题目中已经给出了TITLES表和SALES表的等值条件,空缺处就应该是分店信息表和销售表连接的条件。

  • 第14题:

    现有两张数据表(MySQL数据库)如下:

    x_pt_info x_user_info

    字段 类型 长度 小数位 字段 类型 长度 小数位

    user_id int 11 user_id int 11

    pt_group int 11 user_name varchar 20

    pt_number decimal 10 2 user_work int 1

    描述一下这个SQL语句的作用:

    SELECT b.user_id as user_id,b.user_name as user_name,round(sum(a.pt_number),2) as ptnum from x_pt_info a,x_user_info b where

    a.user_id=b.user_id and a.pt_group=1 and b.user_work=2 group by a.user_id order by ptnum desc

    另外,就你的经验,你觉得该语句是否有改进的余地,如有,请阐述。


    正确答案:
     

  • 第15题:

    Click the Exhibit button to examine the data of the EMPLOYEES table.Which statement lists the ID, name, and salary of the employee, and the ID and name of the employee‘s manager, for all the employees who have a manager and earn more than 4000?()

    A.SELECT employee_id "Emp_id", emp_name "Employee", salary, employee_id "Mgr_id", emp_name "Manager" FROM employees WHERE salary > 4000;

    B.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.employee_id "Mgr_id", m.emp_name "Manager" FROM employees e JOIN employees m WHERE e.mgr_id = m.mgr_id AND e.salary > 4000;

    C.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.employee_id "Mgr_id", m.emp_name "Manager" FROM employees e JOIN employees m ON (e.mgr_id = m.employee_id) AND e.salary > 4000;

    D.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.mgr_id "Mgr_id", m.emp_name "Manager" FROM employees e SELF JOIN employees m WHERE e.mgr_id = m.employee_id AND e.salary > 4000;

    E.SELECT e.employee_id "Emp_id", e.emp_name "Employee", e.salary, m.mgr_id "Mgr_id" m.emp_name "Manager" FROM employees e JOIN employees m USING (e.employee_id = m.employee_id) AND e.salary > 4000;


    参考答案:C

  • 第16题:

    要在users表中插入一条新记录,下面语句正确的是()。

    • A、Insert Into users(id,user_name) Values(100, "luhong")
    • B、Insert Into users(real_name,tel) Values("卢红","6545632")
    • C、Insert Into users(user_name,Email) Values("luhong", "")
    • D、Insert Into users(user_name,Email) Values("luhong", NULL)

    正确答案:A,B

  • 第17题:

    Examine the structure of the EMPLOYEES and DEPARTMENTS tables: EMPLOYEESColumn name Data type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2 (30) JOB_ID VARCHAR2 (20) SALARY NUMBER MGR_ID NUMBER References EMPLOYEE_ID COLUMN DEPARTMENT ID NUMBER Foreign key to DEPARTMENT ID column of the DEPARTMENTS table DEPARTMENTSColumn name Data type Remarks DEPARTMENT_ID NUMBER NOT NULL, Primary Key DEPARTMENT_NAME VARCHAR2(30) MGR_ID NUMBER References MGR_ID column of the EMPLOYEES table Evaluate this SQL statement: SELECT employee_id, e.department_id, department_name, salary FROM employees e, departments d WHERE e. department_id = d.department_id; Which SQL statement is equivalent to the above SQL statement? ()

    • A、SELECT employee_id, department_id, department_name, salary FROM employees WHERE department_id IN (SELECT department_id FROM departments);
    • B、SELECT employee_id, department_id, department_name, salary FROM employees NATURAL JOIN departments;
    • C、SELECT employee_id, d.department_id, department_name, salary FROM employees e JOIN departments d ON e.department _ id = d. department_id;
    • D、SELECT employee_id, department_id, department_name, Salary FROM employees JOIN departments USING (e.department_id, d.department_id);

    正确答案:C

  • 第18题:

    Examine the structure if the EMPLOYEES table: Column name Data Type Remarks EMPLOYEE_ID NUMBER NOT NULL, Primary Key EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) NOT NULL SAL NUMBER MGR_ID NUMBER References EMPLOYEE_ID column DEPARTMENT_ID NUMBER Foreign key to DEPARTMENT_ID column of the DEPARTMENTS table You need to create a view called EMP_VU that allows the user to insert rows through the view. Which SQL statement, when used to create the EMP_VU view, allows the user to insert rows? ()

    • A、CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, department_id FROM employees WHERE mgr_id IN (102, 120);
    • B、CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, job_id department_id FROM employees WHERE mgr_id IN (102, 120);
    • C、CREATE VIEW emp_Vu AS SELECT department_id, SUM(sal) TOTALSAL FROM employees WHERE mgr_id IN (102, 120) GROUP BY department_ id;
    • D、CREATE VIEW emp_Vu AS SELECT employee_id, emp_name, job_id, DISTINCT department_id FROM employees;

    正确答案:B

  • 第19题:

    Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()

    • A、SELECT*FROMemp_dept_vu;
    • B、SELECTdepartment_id,SUM(salary)FROMemp_dept_vuGROUPBYdepartment_id;
    • C、SELECTdepartment_id,job_id,AVG(salary)FROMemp_dept_vuGROUPBYdepartment_id,job_id;
    • D、SELECTjob_id,SUM(salary)FROMemp_dept_vuWHEREdepartment_idIN(10,20)GROUPBYjob_idHAVINGSUM(salary)>;20000;
    • E、Noneofthestatementsproduceanerror;allarevalid

    正确答案:E

  • 第20题:

    Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()

    • A、SELECT * FROM emp_dept_vu;
    • B、SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department _ id;
    • C、SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department _ id, job_id;
    • D、SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM (salary) > 20000
    • E、None of the statements produce an error; all are valid.

    正确答案:E

  • 第21题:

    单选题
    下列关于匿名类正确的是()。
    A

    List<Student>list=new{Id=1,Name=张三};

    B

    varstu=newStudent{Id=1,Name=张三};

    C

    varstu=new{Id=1,Name=张三};

    D

    publicclassvar{}varstu=new{Id=1,Name=张三};


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    Examine the structure of the EMP_DEPT_VU view: Column Name Type Remarks EMPLOYEE_ID NUMBER From the EMPLOYEES table EMP_NAME VARCHAR2(30) From the EMPLOYEES table JOB_ID VARCHAR2(20) From the EMPLOYEES table SALARY NUMBER From the EMPLOYEES table DEPARTMENT_ID NUMBER From the DEPARTMENTS table DEPT_NAME VARCHAR2(30) From the DEPARTMENTS table Which SQL statement produces an error?()
    A

    SELECT * FROM emp_dept_vu;

    B

    SELECT department_id, SUM(salary) FROM emp_dept_vu GROUP BY department _ id;

    C

    SELECT department_id, job_id, AVG(salary) FROM emp_dept_vu GROUP BY department _ id, job_id;

    D

    SELECT job_id, SUM(salary) FROM emp_dept_vu WHERE department_id IN (10,20) GROUP BY job_id HAVING SUM (salary) > 20000

    E

    None of the statements produce an error; all are valid.


    正确答案: C
    解析: 暂无解析

  • 第23题:

    单选题
    下列哪种方式可以在session中保存一个名为"name",值为"newer"的属性()
    A

    request.getSession().setAttribute(“name”,newer)

    B

    request.getSession().getAttribute(“ID”,id);

    C

    request.getSession().setParameter(“ID”,id);

    D

    request.getSession().getParameter(“ID”,id)


    正确答案: C
    解析: 暂无解析