Docker vs. Mysql local server SQLSTATE [HY000] [2003]

I installed a docker with apache2, MySQL, and my project (zend1). I can't import my big database to MySQL in the docker so I set it to the local Mysql Server 5.7 ( port: 3307) where I imported all the data, and now at localhost, I still see

Java and mysql Throttling Share Solutions

We are developing a vehicle tracking system in which several GPS devices keep sending their GPS locations to the server using Tcp connection. Tcp communicator decodes the GPS location and inserts that data into the database and before inserting we do

MYSQL Calculate total minutes of timestamps

I'm trying to sum total minutes from timestamps. my data is like 2017-03-11 14:27:06 2017-03-11 14:27:12 2017-03-11 14:27:16 2017-03-11 14:27:20 2017-03-11 14:27:24 2017-03-11 14:27:28 2017-03-11 14:27:32 2017-03-11 14:27:36 2017-03-11 14:27:42 2017-

Mysql Timestamp plus time

On MySql when I run "INSERT" I want to set the date to " Current time stamp " + 1 minuts I am able to insert the time like this 2017-02-23 00:00:00 but I want it to be added like this 2017-02-23 00:01:00 any ideas ?You can use mysql me

Select users with more than one instance in the database

I have a table with a userID field and an itemID field. I would like to select all of those users that have two or more instances where itemID is the same (that is, if for example there are 3 records where userID = 1 and itemID = 7 then I would like

SQL Inner Join With Multiple Columns

I've got 2 tables - dishes and ingredients: in Dishes, I've got a list of pizza dishes, ordered as such: In Ingredients, I've got a list of all the different ingredients for all the dishes, ordered as such: I want to be able to list all the names of

SQL query on timestamp interval: optimization

I am getting stuck by the execution time of a query. I have a table (no written by me) with a lot of rows (4mio) and a column representing the timestamp. I want to do a query that will keep only the datas between two given timestamp. I am currently u

The database for 'who saw this object also saw ...'

I want to create feature 'who viewed this item also viewed' like Amazon or Ebay. I'm deciding between MySql and non-relational database like MongoDB. Edit: It seems to be straightforward to implement this feature in MySql. My guess is creating 'viewe

Mysql count has joined fields

I have 3 tables: accounts, comments and followers In account I track user info, in comments their comments and in followers, who are they following. I want to create a query where I get basic info of the account, a count of comments and a count of fo

change of data type in the entire database

By mistake I have created my tables with data type int(200), varchar(200), double(200,2) in MySQL. Now I want to change it to int(20), varchar(20), double(20,2). Since the database is very big changing them one by one is a very very difficult task. I

SQL query by adding two columns in the where clause?

I have a database table that contains two scores: scoreA scoreB I am trying to make a SQL query by adding these two values, such as SELECT *,(scoreA+scoreB) as scoreC FROM data WHERE scoreC > 100 ORDER BY scoreC DESC However, it shows an error: ERROR

Adding an account from another table to an existing query

This query is working fine: SELECT posts.titulo as value, as id, posts.img_src as img, posts.id_familia, posts.tiempo, posts.votos, familias.clave, as fm, textos.clave, textos.texto as familia, FROM posts,familias,textos WHERE po

SQL Update Query will not work in PHP

So I've been trying to figure out what the problem is with my UPDATE SQL query and searched through the questions on here only to find out the issue is with the actual text that's being updated in the database table. My PHP app is a simple one just f

How to optimize MySQL queries that have calculations

I have a fully working query but it takes 1.5 secs to load. I am pretty new to MySQL so I know my queries are not the best but is there a way to optimize this? I will be having 5-6 of these queries and it'll take over 10 seconds to load them all. Sel

mysqli insert - but only if it is not a duplicate

This question already has an answer here: if not exists insert in MySql 2 answers I'm a Java developer who just got handed the task of "some quick easy DB stuff" - except I don't know much about PHP/MySQL...I need to insert a record into a DB -

How to clone an entry in a column at all with the same ID?

I'm looking to clone an entry in a database while the id is the same. Each line has its own ID, and then a separate column for the entry I'm looking to duplicate. I'm trying to find any entry with data in this column, and clone it to any other lines

How do I get the last record of my table

How can i get the latest date out of a tabel. Perhaps it is better if i show you what i mean. This is my current tabel output TransactionID Title Date 23132 Locaton 2013-05-17 10:02:04 23131 Novuel 2013-05-16 16:26:45 23130 Novuel 2013-05-16 11:41:21

MySQL Select JOIN multiple tables

I essentially have two groups of tables. 'props_' and 'avail_'. Each with approx. 4 tables which i have joined using UNION ALL. I need to select the properties with the necessary location & sleeps which don't appear in the availability tables for spe

Get column 1 of the same table 1 result

I have a users table and a friends table. I want to get the friendships of 1 user, but getting both user info in results. For example, let's say I have these tables: - users (_id_, username, firstname, lastname) - friends (_#id1, #id2_) Here are some

mysql left with condition on table1

I'd like to do a left join using only certain rows of the first table in mysql. Currently I do something like: SELECT students.* FROM students LEFT JOIN courses ON = WHERE = 6 But will mysql first select rows from t

MySQL - Problem with null = 0

Im working with a mysql database via php. I have a table with some values that are = NULL I select these values in php: $opponentInv = db_execute("Select * from inventoryon where playerid = ".$defendid.";"); $opponentInv = mysql_fetch_

PHP / MySQL Query In loop, how to add to a single query?

I have a query to pull all articles out of the database.. $get_articles = $db->query(" SELECT *, AS id, s.type AS type FROM ".$prefix."articles a LEFT JOIN ".$prefix."sources s ON ( = source_id) WHERE a.type!='trashed'

Can I use a database value right after I insert it?

Can I insert something into a MySQL database using PHP and then immediately make a call to access that, or is the insert asynchronous (in which case the possibility exists that the database has not finished inserting the value before I query it)?What