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…
Tag: mysql
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 …
mySQL – create table error 1064(42000): syntax error
I’m trying to create the table below but I get an error. I double checked and the data types are valid, and a table with this name doesn’t currently exist in the database. I even closed and re-opened my terminal in case this was a glitch. But still no luck. Any idea what’s wrong here? Error …
Only show Warehous where product is not existing – multiply tables mysql
I’ve got three tables. Product, Warehouse and IsIn. Product: productID name price Warehouse: warehousID name IsIn: productID* warehousID* quantity I now want to write a question where i get all warehouses where a specific product does not exist. I can get a table where the specific product are, but when…
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…
Page numbers & total result count in a cursor based pagination
Though it may sound like a stupid question, sometimes it is necessary to show page numbers (and also the last page). What is the best way to calculate total row counts and also calculate page numbers (by providing a page query to return specific page) in a cursor based pagination? Also are all these possible …
How to select all data corresponding to the 3 latest dates for each ID?
I would like to see all the data (all columns) related to the last 3 dates of an ID The result would be in this case: Could you please help me? Answer You can use window functions:
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