Skip to content

Tag: sql

Sql server – recursive delete

I’m trying to delete user’s data and all it’s related data that is located in different tables. All the tables have Foreign Keys but without cascade delete. I investigated some options: Enable cascade delete on all FK, delete and remove the cascade delete. Delete from bottom UP, loop up for …

A query with 3 tables in django

I have 3 classes like this: My question is: How can I make a query to get the devices used by the person “name”? Which needs to pass through the uses class. Answer Life will be easier if you use ManyToManyField, i.e. add this field to the Person model: Then, to get the list, you just need to get t…

sql to combine two unrelated tables into one

I have tables table1 and table2 I want to combine the two tables, which have no common field into one table looking like: table 3 ie, it is like putting the two tables side by side. I’m stuck! Please help! Answer Get a row number for each row in each table, then do a full join using those row numbers:

SQL auto_increment behaviour

My first question is: Can I manually input ID into an auto_increment column of a table? For example: I have 10 records with ID from 1 to 10. Can I manually input the 11 record with the ID of 3 (yes, it’s a duplication!) My second question is: I assume that it’s possible to manually input ID number…