Skip to content

Tag: mysql

How do I load values in txt file to mysql table colum

I have value like this stored in value.txt file I have created table in the below way I am unable to find a way to insert the txt file details in payload columnn of table. I saw load option is there but it is more of entire table oriented. I want the txt files value to be in specific column.

MySQL – Sum revenue while correcting by daily exchange rates

I have two tables Orders table Exchange rates table (cron-job does the job for this) I have to sum the orders total in USD and with the correct exchange rate! How could I achieve that? Is there a common practice? What I have so far is a basic sum: Answer The link you need is that based on the date.

How to make correct query with complicated conditions?

I have this table: I need to select only that band_names which participant set is not changed all time of its existance(date_join == active_years_begin and (date_left is null or active_years_end is null) or (date_left == active_years_end)) ) for all band participants. So here right answer is The Beatles, Wing…

how to combine queries from one table?

I have a table with dates and some data. How can I display data for each month (January, February, March), and also display the amount for three months, the average for three months and the maximum payment in one request? the result should be like this users date pay balance avg(balance) avg(pay) sum(pay) use…

SQL Trigger – Having one is messing up new SQL queries

I am able to manually execute the following code: However, if I try creating a Trigger with the same code as above, I get this error when creating a new user in my database: Can’t update table ‘members’ in stored function/trigger because it is already used by statement which invoked this sto…

Calculate expiry date 3 months from now on MYSQL

So I have been given just the expiry dates for my loyalty cards, I need the query to display all the customers whose card will expire 3 months from the current systems date not hardcoded. Lets say todays 2021-09-30, and the card expiry date for customer1 is 2021-12-12 and the customer2 is 2021-10-18. SO the q…

How to return the number of sets for each date

I am running a query that returns: I need to also return the number of Sets for each date: Answer You may add the count window function to your select clause eg Mysql 8+ Older Mysql Versions You may use variables or aggregates to achieve your count Schema (MySQL v5.5) Query #1 Date Set Data NoSets 2021-07-02 …