SQL Touch a question, SQL elementary syntax questions, high scores

Updated on technology 2024-04-08
10 answers
  1. Anonymous users2024-02-07

    Problem 1 : not exists indicates that when the result set of the subquery is empty, the condition is valid!

    For example, if the student table has data s = 100, then the subquery of the matching record is.

    select * from sc where = 100 and c#='c2'

    If the subquery fails to obtain the result, the data in the parent query S table s = 100 satisfies one of the data of the SQL statement.

    Question 2 : If it is <> the explanation in this query is that if only one student has learned, this student will be displayed, and if none of them have learned, all of them will be displayed.

  2. Anonymous users2024-02-06

    Basic grammar.

    create trigger tri_name

    on table

    for insert/update/deleted

    assql code

    Example: Create trigger tri mc (tri mc: the name of the custom trigger).

    on table (table: the name of the table that was triggered).

    for insert (trigger type: insert, update triggered by inserting data, delete triggered by updating data, and triggered by deleting data).

    asdeclare @kssj datetime (define a variable and do intermediate processing).

    declare @sqbh char(40)

    select @kssj = kssj,@sqbh = sqbh from inserted

    When data is inserted, the inserted data is inserted in the table

    When the data is updated, the updated data is deleted in the table after the table is inserted The data before the update is deleted

    When you delete data, the deleted data is deleted in the table

    Different operations can take out different intermediate data and do processing, in the example to take out the inserted data).

    update table2 set isks = 1,kksj = @kssj where sqbh = @sqbh

    Do the corresponding operation according to the intermediate processing, in the case of the processing of the insertion, and update the inserted value to another table synchronously).

  3. Anonymous users2024-02-05

    Take a closer look at this paragraph**:

    update borrowrecord

    setfrom borrowrecord br , deleted d ,inserted i

    wherefrom borrowrecord br , deleted d ,inserted i

    It means that the alias br is used instead of borrowrecord, d is used instead of deleted, and d is used instead of inserted.

    Got it? good luck!

  4. Anonymous users2024-02-04

    if (object_id('tgr_classes_update_column', 'tr') is not null)

    drop trigger tgr_classes_update_column

    gocreate trigger tgr_classes_update_column

    on student

    for update

    as--column-level trigger: whether the ID field of student has been updated.

    if (update(id))

    beginupdate score set id=** where ..Modify the id=** of the score table

    rollback tran;

    endgo

  5. Anonymous users2024-02-03

    Use triggers, search the Internet for trigger usage.

  6. Anonymous users2024-02-02

    Do you have this sqlserver or oracle or mysql?

  7. Anonymous users2024-02-01

    Two ways.

    1. Triggers.

    2. Stored procedures.

    Personally, I feel that the storage process is better.

  8. Anonymous users2024-01-31

    1 is a constant. Here it just represents existence.

    If there is no data in the inserted or deleted table, select will not produce data.

    If there is data in the table, select displays 1

    Writing 1 here has the same effect as *, exists only determines whether there is data in auspicious and subdued, and will not output the bridge width data.

  9. Anonymous users2024-01-30

    It is best to add an id field to table a, and then if you want to say that the first row id is 1, the second row is 2 and then if you want Chinese units such as meters and kilograms, you just need to add the condition where when taking table a'2'It should be fine.

    Try it, in fact, I'm new to SQL, hehe.

    A and B don't matter much, and you don't need A.

    Select unit = case u001 when'00' then 'm' when '01' then 'kg' when '02' then 'grams'end,* from b) Actually, I think the method on the second floor is good, you can don't need table a, set it directly.

  10. Anonymous users2024-01-29

    A and B don't matter much, and you don't need A.

    Select unit = case u001 when'00' then 'm' when '01' then 'kg' when '02' then 'grams' end,* from b

Related questions
6 answers2024-04-08

1.It is used when something becomes something else, that is, when it indicates the direction of change. >>>More

13 answers2024-04-08

In the case of sqlserver, you can write a database-based trigger in which you can get the name of the table to be operated on, and sqlserver prohibits the user from deleting the specified table. >>>More

6 answers2024-04-08

Describe it as windy.

Rain is a natural phenomenon in the simple present tense. >>>More

16 answers2024-04-08

First, the state stipulates that the time from the employee's resignation application to the official departure is not more than 1 month, so if the company asks you to leave after 1 month, it is not illegal, you had better seize the time to do the handover with the company, and you can also leave in advance if you say that you will not be allowed to leave because you have not recruited anyone. >>>More

10 answers2024-04-08

Hello, her parents hoped she can marry into the nobility and enter the highest ranksHere ranks is the noun plural. >>>More