Operations between SQL tables and SQL table records

Updated on technology 2024-08-07
14 answers
  1. Anonymous users2024-02-15

    I'm not a master, I just know a little SQL statement, I wrote a SQL statement, I want to learn SQL with you (I wrote SQL Server statements, if it's other databases, it may be a little different).

    select employees. Name, Fire Protection System = case when Project Name ='Fire protection system'Then file a case, else'0'end, anti-theft system =case when item name ='Anti-theft system'Then file a case, else'0'end, waterproofing system =case when item name ='Waterproofing system'Then file a case, else'0'end, water system=case when itemname='Piped water system'Then file a case, else'0'end, anti-wolf system =case when item name ='Anti-wolf system'Then file a case, else'0' end

    from(select employee. Name, project name, employee number, number of hours filed.

    from(select employee. Name, item. Project name.

    from Projects, Staff.

    where employees. Number = Item. Item No. *I think your project and staff both tables are made by employees. Number and item. The item number is associated, so it is written as such

    a, project load.

    where Project load. Item No. = Project. Item number *Same as above*

    bgroup by Staff. Name, case when item name ='Fire protection system'Then file a case, else'0'end, case when project name ='Anti-theft system'Then file a case, else'0'end, case when project name ='Waterproofing system'Then file a case, else'0'end, case when project name ='Piped water system'Then file a case, else'0'end, case when project name ='Anti-wolf system'Then file a case, else'0' end

    I don't know if it's right or not, but I hope that the database master can give me some advice.

  2. Anonymous users2024-02-14

    And then look at the research.

    If you really don't understand it, ask me again.

  3. Anonymous users2024-02-13

    It is estimated that since the project is not fixed, the temporary table created will also be created with a stored procedure.

  4. Anonymous users2024-02-12

    Temporary tables can be created, but they are not easy to create because the items are not fixed.

  5. Anonymous users2024-02-11

    The type of birthday column and party member column.

    It is a character type and a date with quotation marks' '

    The digital type is not needed.

  6. Anonymous users2024-02-10

    There are many methods, nested search and join search, especially join search, which is quite the same as merging two tables into one table, a statement is written to the end, nested search is also good, query efficiency is high, the main problem is... Give some practical conditions and requirements, and you ask questions like this, only to see the forest but not the trees.

  7. Anonymous users2024-02-09

    You can try it.

    select a,b,c from table1union all

    select a, b, c from table2: Note that the field type of select must be the same for the two tables.

  8. Anonymous users2024-02-08

    List the table structure, and then describe the requirements.

  9. Anonymous users2024-02-07

    1 All correct: The answer is this.

    insert into table2 select max(autoid),userid,title from table1 group by userid,title

  10. Anonymous users2024-02-06

    Do you want the result to be 2 tables of records displayed in a result set select * from t1

    union all

    select * from t2

  11. Anonymous users2024-02-05

    select * from t1

    unionselect * from t2

    order by companyid

    Hehe, a simple external connection between two tables, I hope it can help you.

  12. Anonymous users2024-02-04

    I can only say simply:

    1.Material dimension table: The main Wu Chong is to record the material of the mausoleum.

    2.Picking flow table: A record of each picking.

    What can be divided into material properties should be divided into that dimension table as much as possible. Reduce the amount of data in the flow meter.

    The above is a personal opinion.

  13. Anonymous users2024-02-03

    Since the tables in the database are all in two-dimensional format, this is what we call a relational database.

    In fact, to put it bluntly, it is the operation of rows and columns, of course, including the operation of tables, and some syntax keywords are given on the first floor.

    Additions, deletions, and changes are all column-based.

    Deleting, creating, and modifying tables are all for tables.

    As long as you understand the relationship between structure and content, and then make more examples, you will be able to SQL.

  14. Anonymous users2024-02-02

    insert: increment

    update: Changed

    delete: Deletes the record.

    truncate: Same as above, but in a different way, this faster drop: delete the table.

    create: create.

    alter: changes the structure of the table.

Related questions
7 answers2024-08-07

First, use the left join to completely find out the 1 table, then use the right join to completely find out the 2 tables, and finally merge the results. >>>More

8 answers2024-08-07

create table [dbo].[Employee Data Sheet] (Number] [Char] (10) Collate Chinese taiwan stroke ci as null, Name] [Char] (10) Collate Chinese taiwan stroke ci as null, Gender] [Char] (10) Collate Chinese taiwan stroke ci as null, Department] [char] (10) collate Chinese taiwan stroke ci as null, salary] [char] (10) collate Chinese taiwan stroke ci as null >>>More

9 answers2024-08-07

The above is based on the id of your table, but it is true that if there is no id, it feels more difficult to delete it directly, but it can be done directly by a rogue method. >>>More

9 answers2024-08-07

The first way is to do a correlation query, which already has the answer. >>>More