Let’s say I have a table real_table with a primary key on column1. I can load data into it like this: But this means I have to specify the PKs manually. Doing it manually is not a huge problem for a relatively small table. I can also do this: But what do I do for a table that has 10
Tag: database
Auto-increment a primary key in MySql
During the creation of tables using mysql on phpmyadmin, I always find an issue when it comes to primary keys and their auto-increments. When I insert lines into my table. The auto_increment works perfectly adding a value of 1 to each primary key on each new line. But when I delete a line for example a line where the primary
How to make it into BCNF
Good morning, I wonder how I can make sure this schema is in BCNF. petition(ID, title, contents, budget, organizationID, official, resultID, applicantID) applicant(ID, name) official(ID, name, department) organization(ID, name, phoneNumber) *Each petition has an official. *Each petition should have more than one organization. This is the hardest option that I cannot handle. With the same petitionID, there can be several
How do I return only the most recent record on a date field split into two
Scenario: Person A takes test B three times in the span of two year. There will be three entries for that person. However, I need to write a query that tells me the number of Persons that have taken a test(just one, the latest test). The problem with this is I have a column labeled, Test_Month (xx) and Test_year(xx). What
For all entries in one table, add to another table
Database looks like this: table1 table2 I want to make a query that passes the same data for all ID’s into table2. So after the query the database would look like the following: table1 table2 I’ve tried to make some INNER JOIN queries, but I can’t seem to make it work. Any suggestions? Answer Do you want this? Normally, ids
One to One Mapping Spring boot
Hello everyone in advance I have a problem with my one to one connection when I try to log in to the “user” I get this error what i need is a one to one connection that does not have to be persistent that means a user can have a player but does not have to have it and the
How many SQL Queries will be executed in the database through this EF
I have the following and want to know how many queries will be executed in the DB through this EF? private static dbContext dbc = new ProfileDBC(); private static IQueryable GetProfile(…
SQLite – Rolling Average/Sum
I have a dataset as shown below, wondering how I can do a rolling average with its current record followed by next two records. Example: lets consider the first record whose total is 3 followed by 4 and 7 ,Now the rolling 3 day average for first record would be 4.6 and so on. Expected output: PS: Having “null” value
How to delete row contain specific string on it in SQL Server
There are lots of rows that contain ’08:28:00.000′ in my table,like this one: I want to delete all the rows that ‘datetime’ contains ’08:28:00.000′.Instead of deleting this kind of rows one by one,is any command can delete all the rows than datetime contain ’08:28:00.000′? Answer Try using a range delete query here, after extracting time from the datetime column:
Depending on column value, query different tables
I have table A where each IDENTIFIER value is unique. Depending on whether its CC or DC, I need to join it with different tables, for example if its “CC_” I need to map it to table B and if its “DC_” I need to map it to table C. TABLE A: TABLE B: TABLE C: I want the result