Skip to content
Advertisement

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 really just hacks to get around

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 like numbered sequence :1, :2, :3, etc. the module MySQLdb only supports %s or%(name)s parameter

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 subtract date values, e.g. start_date from

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 the where clause is executed before of the select clause and for this

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 status

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:

How to COUNT “accounts” only if character/user exist

I have 2 tables – “accounts” and “players” I’m using this query to COUNT accounts Accounts table estructure: Players table estructure: * Let’s say the query counts 10 accounts but only 3 accounts have a character/user created. I would like to know how to count only those 3 accounts without taking in consideration how many characters/users has the account, so

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, or TIMESTAMP object. I

Advertisement