Skip to content

Tag: mysql

Get items from next week

I was starting to do a query such as: The problem with this is that items from previous years will also show up here. What would be the best way to do this query — I’m hoping I can still use an index on the query on the date_inserted field, which is why I’m asking this here Answer I would

[21000][1242] Subquery returns more than 1 row

My Query: Here I get the error – [21000][1242] Subquery returns more than 1 row By the method of exceptions, I determined that the error in this query string: How to make the correct request so that there is no this error? Thank! Answer Two common ways are aggregation and limiting: However, those are re…

Load table from Oracle to MYSQL using python

Tried below code to load rows from Source(Oracle) to Target(MYSQL) Error Edited Updated Code_:- Error: Answer In Python, while all strive to adhere to PEP 249, no two DB-APIs are exactly the same especially in parameter implementation. Specifically, while the module, cxOracle, supports arbitrary placeholders …

How to do date math on SELECT columns?

The following query works perfectly: It returns two row each with two dates Instead of returning these two values in a table, I’d like each row to also have the difference of those two dates, in years or days. So I have two questions: What’s the general rule for combining columns? How do I subtrac…

using alias to where clause query mysql

i have query but mysql showing this error: Unknown column ‘Aktifitas’ in ‘where clause’ why mysql Alias cant be use in Where clause, but is there something I missing? Thanks in advance. Answer You can’t use column’s alias in where clause you must repeat the code (because th…

Mysql query dosen’t provide the result needed

I’ve been trying to figure this one out for days but can’t come up with a solution. Here are the table schemes. This is my current query. The problem is that the query returns as long as there is one article with status bigger than 1. I need a query where all the articles of that order have a stat…

sql query for grouping column into row

So, I have table like this and I want to make query so the result is like or I have try to use GROUP BY but I dont know how to get the slot number. Please help, thank you! Answer With conditional aggregation: See the demo. Results: And for the 2nd case use group_concat(): See the demo. Results:

Select current week, starts from Monday instead of Sunday

I’ve managed to select the data from the current week but the week itself starts from Sunday which is not the right format for me, it should starts from Monday. I’m using MySQL to query the data. Answer You can use this little formula to get the Monday starting the week of any given DATE, DATETIME…