I am struggling to understand if this query is possible. I have 3 tables, User, Account, Loan. 2 users are linked by an account, and any loans facilitated between the 2 of them gets linked to the …
Tag: mysql
How can I make this select lookup another table and find first match?
I have a database of phone call data from our phone system that I am trying to create a report on. These phone calls match up to a table of internal and external numbers. The report needs to try to match the phone call to an external number in our database first and if there is no match try to
How query two different Sum from the same table for the same column but with different condition?
I would like to fetch the sum of field TOTAL for active users and sum of field TOTAL for inactive users. Expecting is the query that results activeTotal = 15 and InactiveTotal = 50 SELECT SUM(actUser.total) as activeTotal, SUM(inActUser.total) as inactiveTotal FROM user actUser JOIN user inActUser ON inActUse…
How to change max_connections_per_hour in XAMPP?
In my production environment I’m getting this error: I don’t have this problem in my development environment so I need to set the max_connections_per_hour to 500 in order to replicate it. How do I do this? My database is run from the XAMPP control panel. I don’t see this variable name in my.…
Is there a way to use MySQL fulltext to search related tables?
I have a table called persons which contains data about, well, people. It also contains foreign keys to another table. I’d like to make a fulltext index that is able to search the related tables for …
Alias for a mysql case statement
I would like to set an alias for the case statement in the following query. The query works fine but the last column header shows as the case statement in full. You can have a look at what I mean at dbfiddle. I am trying to get the difference between the current salary at a row and the next salary
Mysql group by included the whitespace as same value
I have this table and this value I need to group by the data and count how many data that have same value, so i used group by and count the result not what i expect because the data for ID 1,2,5, and 3 is counted as same value like below result how could i make the result like expected
inserting to database from query in python
I have a table of tweet data my_tweets containing these columns: tweet_id, text, created_at, sentiment My tweet data is being streamed live and simultaneously inserted into the table. I am writing code using Vader to get the sentiment of the text. At the moment, tweet_id, text, and created_at are all populate…
MySQL – summing up products from several orders
I want to sum up the number of items purchased from several orders. I have this query, however it shows me each order on a separate row. I want have it all added up in one row. This is woocommerce database. Example output: and this is how it should be: Answer You want the aggregation string over all those ite…
MySql improve GROUP BY ORDER BY query with index
I have a table like this: the goal is to query how many products have been sold per day, so the query is: The output is: Ok. Now let us suppose we have a scenario with several records and this query has to be run several times per day, we need to care about performance now in order to retrive