I am trying to create a simple MySQL query to get the sales data for each month of the year, grouped by monthname and SalesName. CREATE TEMPORARY TABLE Cal (monthid INT, monthname VARCHAR(50)); INSERT …
Tag: mysql
From sqlite syntax to mysql syntax
I’m having some troubles moving from sqlite syntax to mysql syntax. Does anybody know a ressource showing the basic syntax in sqlite and its equivalent in mysql ? In my particular case, I want to transform this sqlite code into mysql one: For the moment, I did that: DROP TABLE IF EXISTS post; But I got …
SQL Insert JSON into table column
while searching for a way to insert array into single db columns, I found an article about inserting JSON string. However it wasn’t explained how. I tried to search and find the way with no success. I have the following table: What i want to do is insert a Json arry in the address column. like: I though…
subquery shows more that one row group by
I am trying to get the data for the best 5 customers in a railway reservation system. To get that, I tried getting the max value by summing up their fare every time they make a reservation. Here is the code. this throws the error:[21000][1242] Subquery returns more than 1 row If I remove the group by from the…
Compare previous row’s date in grouped query [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I calculate hours that the air temperature below 7.22. I want to do this calculation on the S…
SQL column default value set using row wise operations
Is it possible to set a default value in a SQL column to be consisted of other columns? For example, in the table below is it possible to have the EndDate default to StartDate + NoOfDays? So when …
PHP Prepared MySQL UPDATE Statement with Variable inside of a string
I am trying to include a variable inside of a string in an update query but seem to be having trouble. I am just now updating all of my old websites to use prepared statements so I am not that familiar with them yet. What do I need to do to get the string and variable connected in the query.
How to get all items that are tagged Tag1 AND Tag2 AND … for a 3-table tag solution
So I implemented a 3 table tag solution, als indicated in this classic post (so-called “Toxi” solution). Everthing works splendid, the only thing I struggle with is to get all items that are …
Possible for a MySQL trigger to silently fail?
I’m pulling my hair out trying to debug something. We have large raw tables where ecommerce data gets added to at high. We have summary tables that are populated via insert, update, and delete triggers which are used when users query from our UI. So, those two tables should “match” which is …
How to query many-to-many relation with features table (AND condition)
I guess this is a common setting, but as I don’t do that much SQL work, I can’t get my head around this one… So, I’ve got a bunch of songs that have certain features (style of music, mood etc.) and …