Skip to content

Tag: mysql

Add additional column to the query output

I have the following query that is grabbing data from a table and combining all the products into one column and counting the quantity of that order. I need to add an additional column to the output though, how can I also add ship_date? This is how the original table is laid out: And this is how the query out…

Query to find people with multiple names

I’m working on a fairly big project that allows users of my client’s site to search for people they used to know who might’ve changed their names, primarily due to marriage. Basically, users sign up with all the names they’ve ever used and the data gets entered into a MySQL database. T…

My SUM query returns 2 rows, need some advise

I am getting 2 rows(9500) for 111 in the result, could you please advise on the right approach, I need like, Balance = (sum of bought – sum of sold) Query Answer You can use conditional aggregation: If you want this for only one account, you can add a where clause:

How to find records within a certain timeframe based on another field

How do I find all records 7 days before a field in an SQL database? I need to find all transaction dates that were placed 7 days before the pickup date of the same record. I am currently using SequelPro so that my have an effect on available syntaxes. This is currently my table that I am pulling the records

INT type in SQL max value calculation

I am currently learning SQL. When looking at the INT, I came to the understanding that an INT type is 4 bytes long, which translates to 8 bits each byte, leading to each INT being 32 bits. However, for INT it is said that the max value for unsigned types is (2^32)-1 where the -1 is accounting for 0 value.

Find record that the least amount appears in MySql

I have 2 tables Booked Books I’m currently working on this query but the result is not correct. Output The result that i want is Can you help me to fix it? Thanks. Sorry for my bad english Answer Your question lacks the clarity but to my instinct of what you have posted may be this will work, as far

How to read JSON value in MySQL

The JSON output I need to insert into my database but my source code throws an error: The source code: Can anyone help me with this, as I need to get values for open, close, high and low. error: Answer you have 5 columns, hence 5 bind variables. Your insert template is over complicated with any database opera…