Skip to content

Tag: mysql

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…

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…

MySQL Multiple Conditions in Grouped Data

I am trying to see how many users have clicked on an ad campaign and signed up afterwards. My Logging table has the columns IP, UserID, and Data (this has the $_GET info like utm_source = newsletter). A user may click a link in newsletter and then later sign up on my website (which is indicated when they have…

MySQL customized exists query performance

Because of using Hibernate, I cannot write a JPA query using exists like this (I translated it to pure SQL query): So I have to write an alternative query to check existance of activated accounts. After reading several suggestions on this website, I see a replacement: My question is: Is this bad for performan…

SELECT rows with MAX id minus 1 with group by

I have a table with id, city_id, and stock which looks like this. id city_id stock 1 1 1000 2 2 500 3 3 11000 4 2 600 5 3 12000 6 1 2000 9 3 13000 10 1 3000 11 1 4000 12 2 700 To select the latest stock values for each city_id I used the following query,