Skip to content

Tag: sql

Migrating from sql to mysql

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…

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

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. …