Skip to content

Tag: mysql

count and sum in case statement

What is the difference below if I use case instead of sum? I believe I would get the same output? Thanks! Answer The three are equivalent. All of them count the number of rows that meet the particular condition (salary > 100000). All return 0/1 and would not return NULL values for the column. From a perfor…

shopping cart with PHP and connected to the MySQL

Good evening, I am currently working on the implementation of a shopping cart through PHP and MySQL, I am getting the following error at line 172 onwards, I have been looking at the quotes but I cannot find the problem, what could be the solution to this? I have been changing this cart from a mysqli version o…

Join two tables bring mismatch values MYSQL

I have two tables with >4million records i need to make a select query with where two columns match bring both tables value on this match and then i will insert that into a 3rth table: This is table A: (bitfinex) This is table B: (Kraken) I need to do a SELECT where timestamp and exchange_pair matches, as …

How to group by two columns in mysql

I am building a chat website, I have a table that contains the following columns, from_id, to_id, messages. The from_id is the id of the user that the chat is from and the to_id is the id of the user the chat is sent to. Now I want to get all the chats but I also want to group it

Convert utc string to date SQL

I’ve a column sample_date in form of string as 200912301111230000000000 (UTC Time).How can I convert it from string to datetime in form of yyyymmdd using SQL select statement? Answer As you only want yyyymmdd, which is the first 8 chacters of your string, it is enough to simply use LEFT I added the ST_T…

Select everyone with the same ips

There is a table of users users: ETC… It is necessary to select all users with 1 ip. I tried to do it, it doesn’t work, not what I need to choose. Answer For MySQL 5.x use