I have for tables A Login History An IP To Location Table An Account Table Some Orders All tables have fitting indices for this problem. My goal is to fill the country code of the orders with the country from the ip2location table. I have a login history and because I want to make the problem not more complic…
Tag: mysql
How to select where there isn’t an entry in pivot table relating to X id
In my database I have a table of notifications types that looks something like: A table for events: And a pivot table event_called_notifications to keep track of what type of notification have been called already for each event: I would like to select all the events that don’t haven’t have a parti…
SQL get ids with minim 3 common values
Can someone help me to get all ids with the same color from this table? Thank you Should return 1, 3, 9 Answer You can try next query: Check it on SQLize.online
Group data by foreign key and date with total by date
I need help to select daily payments made and group by the organization and date. Group by date, then the total number of payments and the sum total amount of payments for each day Tables are as …
MYSQL: Get second last record for every customer from a table
my table looks like this ID DATE customer_id 1 2020-10-01 10 2 2020-10-01 11 3 2020-10-02 10 4 2020-10-03 10 5 2020-10-03 11 What i am trying to fetch from the list …
MySQL result select SUM from the database
I’ve the following tables and I try to select from table1, table2 and table3 and sum them in total: CREATE TABLE `tbl_cars` ( `carID` int(11) NOT NULL, `car` varchar(255) NOT NULL, `product1` …
Type introspection in mysql query
Is there a function in mysql that tells what type the evaluated expression/column/literal is in a query? I don’t mean the information schema, but something like: And I would get something llike: This is mainly for debugging purposes. Answer No, there’s no function for what you’re describing.…
MySQL multiple columns in ALL clause [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 Why it is not allowed to do the following? But it is possible to do Answer Assuming that this…
Change mysql auto increment id column value
I have a mysql table with an gpid AUTO_INCREMENT NOT NULL UNIQUE column. After filling this table (which has 50M+ entries), I have realized that mysql still increments AUTO_INCREMENT columns if transaction fails because of an IntegrityError, and understandably so. The results are gaps in AUTO_INCREMENT column…
Populate table with data stored in separate tables
I have a MySQL database separate_data, which consists of 200 tables with random names (for example first_table, second_table, …) Each of these tables have the same structure and indexes. The total size is about 30GB. I would like to copy all this data to a new MySQL database called new_database, in the …