I want to transfer a database that I created with sql server with the information in mysqle. An example sql file is as follows No connection to the database should be interrupted during this migration. SQL File Answer Given the length of the script, it would be best to you use an online converter. A good choi…
Tag: sql
Spring boot and jpa query @P0
I’m trying to run the following query but I keep getting the syntax error @P0, I also tried not to use parameters but “?” and still not working, my guess is that the string is not placed under ” and it ends up just next to bulk, but as soon as I place the single quote I get the error
Putting constraint on an attribute gender so that it only accepts ‘F’ or ‘M’ characters
I am doing an assignment which is implementing a database that has book, author, publisher and people tables in it. I have to put constraint on the gender attribute of my Author table so that the only characters in a component for this attribute can be ‘F’ or ‘M’. I only thought of CHA…
Extracting original email and remove email alias in emails
I’m trying to get the primary email from aliases, for example, I have the following examples and I need to normalize them. from “test.me@email.com” to “testme@email.com” from “test+me11@email.com” to “test@email.com” from “test.me.123+22@email.com…
Insert selected columns from one table to another SQL
I have two separate databases in the same host (localhost:3306). I have one table from the first database and a second from the other database. Here is 2 screenshots to become more clear I need to match: Is there any automatic way with a software? Need I to write some specific query to copy these 4 columns fr…
How to take some value from value in one column in Teradata SQL?
I have table in Teradata SQL like below: The first value is always: “O|” then there is 4 numbers and so on… I need to create new column only with these 4 numbers code, so as a result I need something like below: How can I do that in Teradata SQL ? Answer Use STRTOK
Iterating through a list Python SQL
I’m trying to search a database, by iterating through a list of search values. I’m almost there as this works for integers but not strings. The code below won’t work, but if I replace the list values with numbers it does: Answer It’s because you have to enclose strings in quotation mar…
Calculate percentage on an MySQL query
I have a query that returns some counts of data as follows, basically this table is posts and will contain either inbound or outbound posts. I want to make a query that will return the percentage of outbound posts. e.g This returns something like the following… How would I modify the query above so it r…
Create relationship between 2 tables JPA
Need help with setting up table relationships. So, there are 2 entities – Section and Period. 1 Section has many Period, but 1 Period do not belongs to any specific Section. I implemented this relationship as follows: created an additional table SectionCodes with an external key on Section (more in diag…
How to select rows where multiple values do not exist
Scenario: Charlie, Amy and Robert have each filled out a survey which asks the user to select all the sports they are interested in. The question is multiple choice. In the table surveyData each row represents one of the answers each user chose. so Charlie(0001) chose basketball, rugby, acrobatics and darts. …